Reputation: 1714
I generated a JAX-WS client (proxy API) using JAXWS-RI wsimport.bat from a WSDL having as namespace "http://a.mydomain". I'd like to reuse the same generated proxy against a service having as namespace "http://b.mydomain" but targetnamespace "http://a.mydomain" is harcoded all over the generated classes.
Does anybody know any good solution to this problem using JAXWS-RI or any other JAXWS implementation ? I'd like to prevent from regenerating proxy classes using the new WSDL/namespace.
Thank you for any piece of answer.
Upvotes: 4
Views: 1860
Reputation: 157
Steps include:
Create the Service instance using the Service.create method
for which you need to know wsdl location, service name, and name space URL of the service.
e.g.
URL wsdlLocation = new URL("http://example.org/my.wsdl");
QName serviceName = new QName("http://example.org/sample", "MyService");
Service s = Service.create(wsdlLocation, serviceName);
Get the service proxy (service port for connecting) using Service.getPort() method.
For this you need to know endpoint implemenattion class name.
e.g. MyService port = s.getPort(MyService.class);
you can now call methods through proxy. change the name space URL as per your requirements.
Upvotes: 1
Reputation: 3394
The Jax-ws RI does create a constructor like this:
public SomeWebServiceEndpoint(URL wsdlLocation, QName serviceName)
In the QName element you can specify a namespace during runtime (or use a different WSDL location, for example PROD or TEST).
So you either can subclass your webservice into a new class, or use a different wrapper to call them.
Upvotes: 0