0

I am new to java WS and WSDL. I used wsdl2java to create java classes for my web service client and there was a class created with <Service Name>Service extends javax.xml.ws.Service

Please let me know what is the use of the class

4

1 回答 1

0

I think of this as a 'locator' or 'factory' which can be used for making client-side (proxy) instances of the service. For example (where 'Example' is the Service Name):

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();

Though with CXF you can use utilities such as the JaxWsProxyFactoryBean and ignore the <Service Name>Service class. Eg:

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();
于 2011-10-30T23:20:58.610 回答