views:

158

answers:

1

I'm trying to configure my JAX-WS Client to switch between test/production enpoint without having to re-generate proxy classes with wsimport.

The service I'm trying to consume use different WSDL's in test and production. For example the targetNamespace is different, as well as the soapAction address.

I've tried using Springs JaxWsPortProxyFactoryBean and have managed to point to the different wsdl depending on the deployment environment, but even though I point to production, it still uses the WebMethod action addresses from test. I guess this is because they are hard-coded in the service interface that was generated using wsimport pointing to the test-wsdl.

Anyone know if it is possible to switch between wsdls using different targetNamespace and action addresses without re-generation proxies?

A: 

You can override the endpoint address property:
https://jax-ws.dev.java.net/guide/How_to_invoke_and_endpoint_by_overriding_endpoint_address_in_the_WSDL.html.

//Create service and proxy from the generated Service class.
HelloService service = new HelloService();
HelloPort proxy = service.getHelloPort();

<b>((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
                                                    "http://new/endpointaddress");&lt;/b&gt;

proxy.sayHello("Hello World!");

I'm not sure from your question if you need to override other parameters as well.

Dave
Thanks for your answer, the problem is not overriding the endpoint address. See comment above.
ebaxt