SOAP 客户端端口混淆 [英] SOAP Client Port Confusion

查看:73
本文介绍了SOAP 客户端端口混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 wsimport 生成 SOAP 客户端类.然而,问题是当服务器在端口 8080 上运行时,有一个代理可以通过端口 80 从 Internet 访问它.在 WSDL 中,服务器端口 8080 仍然被指定.

现在,当我连接到服务器时,客户端请求的第一件事就是 WSDL.然后它检索此 WSDl 中的 URL 并尝试使用它连接到服务器,这显然失败了,因为端口 8080 无法从外部访问.

有没有标准的方法来解决这个问题?

谢谢.

解决方案

如果您的客户端代码成功获取 WSDL,那么您可以使用以下内容显式指定端点地址:

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

最后一行覆盖了 WSDL 中的端口 URL,这是内部的.

我有更多关于使用 wsimport 的细节:http://shrubbery.homeip.net/c/display/W/Consuming+a+Web+Service+with+Java+6+and+JAX-WS>

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.

解决方案

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

这篇关于SOAP 客户端端口混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆