Is there a JAX-WS implementation that supports a dynamic namespace in the generated client?

I created the JAX-WS client (proxy API) using JAXWS-RI wsimport.bat from WSDL having the namespace " http: //a.mydomain ". I would like to reuse the same generated proxy for a service that has the http: //b.mydomain namespace , but targetnamespace " http: //a.mydomain " is encoded for all the generated classes.

Does anyone know a good solution to this problem using JAXWS-RI or any other JAXWS implementation? I would like to prevent the recovery of proxy classes using the new WSDL / namespace.

Thanks for any answer.

+4
source share
2 answers

The steps include:

  • Create an instance of the service using the Service.create method for which you need to know the location of wsdl, the name of the service, and the URL of the service namespace.
    e.g. wsdlLocation URL = 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 connection) using the Service.getPort () method. To do this, you need to know the class name of the endpoint. e.g. Port MyService = s.getPort (MyService.class);

Now you can call methods through a proxy. change the namespace url to suit your requirements.

+1
source

Jax-ws RI creates such a constructor:

public SomeWebServiceEndpoint(URL wsdlLocation, QName serviceName) 

In the QName element, you can specify a namespace at run time (or use a different WSDL location, such as PROD or TEST).

Thus, you can either subclass your web service into a new class, or use another shell to call them.

0
source

Source: https://habr.com/ru/post/1304895/


All Articles