开发者

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

开发者 https://www.devze.com 2022-12-24 02:09 出处:网络
I generated a JAX-WS client (proxy API) using JAXWS-RI wsimport.bat from a WSDL having as namespace \"http://a.mydomain\".

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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号