基于Jax-ws的几种访问服务的方式
方式1:
可以看到在WSDL中会有一个
<wsdl:portType name="CarShop"> ......................</wsdl:portType><service name="CarShopService"> <port name="CarShopPort" binding="tns:CarShopBinding"><soap:address location="http://cccc.eb.com/xmlapi/shop/car/v1"/> </port></service>
@javax.xml.ws.WebServiceClient(name="CarShopService", targetNamespace="urn:expedia:wsapi:car:v1", wsdlLocation="com.expedia.wsapi.car.v1.wsdl")public class com.wsapi.car.v1.CarShopService extends javax.xml.ws.Service {
WebServiceClient annotation = CarShopService.class.getAnnotation(WebServiceClient.class);wsdlUrl = new URL(CarShopService.class.getResource(CarShopService.class.getSimpleName() + ".class"), annotation.wsdlLocation());qName = new QName(annotation.targetNamespace(), annotation.name());m_service = new CarShopService(wsdlUrl, qName);m_port = m_service.getCarShopPort();
URL createOrderURL = new URL(m_client.getEndpoint() + "?wsdl");QName qName = new QName("urn:com:shop:car:v1", "CarShopService");CarShopServiceo cs = new CarShopService(buyCarURL, buyCarQName);CarShopPort port = cs.get****();