JAX-WS client without having to generate new proxies when switching between test/production
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 targetName开发者_开发百科space and action addresses without re-generation proxies?
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");</b>
proxy.sayHello("Hello World!");
I'm not sure from your question if you need to override other parameters as well.
精彩评论