jax-ws Web服务的端点始终是localhost [英] jax-ws webservice's endpoint is always localhost

查看:53
本文介绍了jax-ws Web服务的端点始终是localhost的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的需要你的帮助.我读到jax-ws Web服务的wsdl将针对每个请求即时生成.这样,诸如soap端点之类的地址将被调整为请求url.

I really need your help. I read that the wsdl for a jax-ws webservice will be generated on the fly for every request. By this, the addresses like the soap endpoint will be adjusted to the request url.

就我而言,无论内部请求还是外部请求,地址始终引用为localhost:8080.

In my case it, no matter wheather internal or external request, the addresses are always refered to localhost:8080.

某人有线索我该如何处理这个问题?

Does sb have a clue how can I handle this issue?

预先感谢

也许我没有很好地描述我的问题.

Maybe I haven't described my problem very well.

  1. 我有一个用jax-ws创建的ws
  2. 将其部署在tomcat服务器5.5.17上
  3. 使用本地ip访问可以正常工作 http://192.168.1.20:8070/mywebservice?wsdl
  4. 无法使用外部IP进行访问. ws引擎"使用本地ip而不是外部IP重写网址 external.domain.de:8070/mywebservice?wsdl
  1. I have a ws created with jax-ws
  2. Its deployed on a tomcat server 5.5.17
  3. Access with local ip works fine http://192.168.1.20:8070/mywebservice?wsdl
  4. Access with external ip doesn't work resp. the ws "engine" rewrites the url by using the local ip and not the external one external.domain.de:8070/mywebservice?wsdl

对于external.domain,wsdl中的所有URL都将重写为本地ip 到xsdschemaLocation和soap:address位置

For external.domain all urls in the wsdl are rewritten to the local ip To the xsdschemaLocation and the soap:address location

代理服务器有问题吗?通过代理的请求使Web服务认为它是本地访问而不是外部访问.

Could the proxy server the problem? Request through the proxy makes the webservice think that it is an local access and not a external.

如何在服务器端防止这种行为?web.xml或sun.jax中的更改(遗憾的是,无法在客户端上进行更改)

How can I prevent this behaviour on server side?Changes in web.xml or sun.jax (Changes on client side are regrettably not possible)

推荐答案

通过外部代理访问Web服务时,这是一个经典问题.

This is a classic problem when accessing web-services thru external proxies.

要使其正常工作,您必须执行以下操作

For this to work properly, you have to do the following

1)在Tomcat的server.xml中添加另一个HTTP连接器.说在端口8071上,只需复制8080连接器Dfn.并将端口设置为8071.

1) Add another HTTP connector in your Tomcat's server.xml. Say on port 8071, just copy the 8080 Connector Dfn. and set the port to 8071.

2)并在该连接器的defn中.您必须将外部IP和端口添加为proxyHost和proxyPort.

2) And in that Connector's defn. you have to add the external IP and Port as proxyHost and proxyPort.

即您的server.xml中应再包含一个Connector条目,类似这样

i.e. your server.xml should contain one more Connector entry some thing like this

<Connector port="8071" protocol="HTTP/1.1"
   connectionTimeout="20000"
   redirectPort="8443"
   proxyHost="external.domain.de" proxyPort="8070" />

并确保将与端口8070上的external.domain.de的连接转发到192.168.1.20和端口8071,而不是8070.

And make sure that Connections to external.domain.de on port 8070, get forwarded to 192.168.1.20 and port 8071, instead of 8070.

假设您要在内部和外部访问WS,我告诉您设置一个新的连接器.这样,8070上的内部端口连接器就不会使用proxyhost并更改内部请求的主机名,但是通过端口8071通过external.domain.de来自外部源的任何请求都将获得external.domain.de作为主机名和8070作为端口.

I told you to setup a new connector, assuming you would want to access the WS internally as well as externally. That way the internal port connector on 8070, does not use proxyhost and change the hostname for internal requests, but any requests coming from external sources via external.domain.de on port 8071 , will get the external.domain.de as hostname and 8070 as port.

如果仅从外部客户端访问您的WS,那么您实际上并不需要2个连接器,只需将proxyHost和proxyPort指令添加到8070连接器即可. 但请注意,即使是内部请求,现在也将主机名视为external.domain.de.

If your WS is going to be accessed only from external clients, then you don't really need 2 connectors, just add the proxyHost and proxyPort directives to the 8070 connector and you're done. But be warned, that even internal requests, will now see the hostname as external.domain.de.

更多信息@ https://tomcat.apache.org /tomcat-5.5-doc/config/http.html#Proxy_Support

这篇关于jax-ws Web服务的端点始终是localhost的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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