问题
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