【发布时间】:2011-07-05 05:05:22
【问题描述】:
我是 java WS 和 WSDL 的新手。
我使用 wsdl2java 为我的 Web 服务客户端创建 java 类,并且有一个使用 <Service Name>Service extends javax.xml.ws.Service 创建的类
请告诉我这个类有什么用
【问题讨论】:
我是 java WS 和 WSDL 的新手。
我使用 wsdl2java 为我的 Web 服务客户端创建 java 类,并且有一个使用 <Service Name>Service extends javax.xml.ws.Service 创建的类
请告诉我这个类有什么用
【问题讨论】:
我认为这是一个“定位器”或“工厂”,可用于制作服务的客户端(代理)实例。例如(其中 'Example' 是 服务名称):
ExampleService locator = new ExampleService();
locator.addPort( ExampleService.Example, SOAPBinding.SOAP11HTTP_BINDING
, "http://myserver:8080/myapp/services/example" );
// now get the instance
Example example = locator.getExample();
尽管使用 CXF,您可以使用 JaxWsProxyFactoryBean 等实用程序并忽略 <Service Name>Service 类。例如:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Example.class);
factory.setAddress("http://myserver:8080/myapp/services/example");
factory.setUsername("user");
factory.setPassword("password");
Example example = (Example) factory.create();
【讨论】: