snowflake
snowflake

Reputation: 1714

Is there any JAX-WS implementation that support dynamic namespace in generated client?

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

Answers (2)

Manisha
Manisha

Reputation: 157

Steps include:

  1. 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);

  2. 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

mglauche
mglauche

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

Related Questions