SOAP Client Port Confusion

巧了我就是萌 提交于 2021-02-05 09:34:27

问题


I'm using wsimport to generate SOAP client classes. The problem, however is that while the server is running on port 8080, there is a proxy that makes it be reachable from the Internet on port 80. In the WSDL, the server port 8080 is still specified.

Now when i connect to the server, the first thing the client request is the WSDL. Then it retrieves the URL in this WSDl and tries to connect to the server with it, which obviously fails because the port 8080 is not reachable from outside.

Is there a standard way to resolve this problem?

Thanks.


回答1:


If your client code gets the WSDL successfully then you can specify the endpoint address explicitly with something like this:

ExampleService exampleService = new ExampleService();
Example example = exampleService.getExamplePort();
BindingProvider bindingProvider = (BindingProvider) example;
bindingProvider.getRequestContext().put(
    BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
    "http://ws.someservice.com:80/soap/ExampleBean");

That last line overrides the port URL in the WSDL, which is the internal one.

I have more details on using wsimport here: http://shrubbery.homeip.net/c/display/W/Consuming+a+Web+Service+with+Java+6+and+JAX-WS



来源:https://stackoverflow.com/questions/5791002/soap-client-port-confusion

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