“Portable” JAX-WS client

大兔子大兔子 提交于 2019-12-03 09:32:48

问题


I deployed a JAX-WS Service and use wsimport to generate client code. Because I run wsimport on localhost, I got the client code with binind on "localhost" address.

But I want to reuse those client code on other computers which access my deployed service with a public IP y.y.y.y. How can dynamically use those (once) generated client code to access my service. (The ip of service may change...)


回答1:


This is covered in the FAQ of JAX-WS:

Q. How can I change the Web Service address dynamically for a request ?

((BindingProvider)proxy).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "..."); 



回答2:


Sure. Take a look at the JBoss example. Here's the relevant code snippet:

BindingProvider bp = (BindingProvider) port;
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://your.wsdl.location");

Usually the WSDL is generated and therfore the WS provider inserts the relevant URLs into the WSDL.



来源:https://stackoverflow.com/questions/1668245/portable-jax-ws-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!