java 如何从使用 Spring 部署的 JAX-WS webservice WSDL 更改自动生成的soap:address

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13587869/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 13:18:49  来源:igfitidea点击:

How can I change the autogenerated soap:address from a JAX-WS webservice WSDL deployed with Spring

javaweb-servicesspringjax-ws

提问by drublik

I have a webservice implementation generated using wsimport from a WSDL. This service is deployed in a Tomcat server in a Spring webapp. The spring configuration file (only the webservice part) is like this

我有一个使用 wsimport 从 WSDL 生成的 web 服务实现。该服务部署在 Spring webapp 中的 Tomcat 服务器中。spring的配置文件(只有webservice部分)是这样的

<wss:binding url="/fooService">
    <wss:service>
        <ws:service bean="#fooService">
    </wss:service>
</wss:binding>

When I deploy this webapp in tomcat, I can get the WSDL if I go to

当我在 tomcat 中部署这个 webapp 时,如果我去,我可以获得 WSDL

http://localhost:8080/foo/fooService?wsdl 

and the wsdl soap:address property is like this:

wsdl soap:address 属性是这样的:

<service name="FooService">
    <port name="FooService" binding="tns:FooServiceBinding">
        <soap:address location="http://localhost:8080/foo/fooService"/>
    </port>
</service>

And for now, it's all ok.

现在,一切都很好。

The problem is that in production, we have an Apache web server and this server redirects the requests to Tomcat. It works too, but when we get the WSDL, the soap:address is still localhost:8080 and we need this to be the public url to the webservice.

问题是在生产中,我们有一个 Apache Web 服务器,该服务器将请求重定向到 Tomcat。它也可以工作,但是当我们获得 WSDL 时,soap:address 仍然是 localhost:8080,我们需要将其作为 Web 服务的公共 url。

Any ideas?

有任何想法吗?

Thank you very much.

非常感谢你。

采纳答案by drublik

Well, I've found one solution:

好吧,我找到了一种解决方案:

It seems that JAX-WS generates this property automatically. I've found that other webservice frameworks implementations, allow the user to change this by hardcoding the url in a property, but it seems that JAX-WS doesn't. Somebody knows if there is some way?

似乎 JAX-WS 会自动生成此属性。我发现其他 web 服务框架实现允许用户通过在属性中硬编码 url 来更改它,但 JAX-WS 似乎没有。有人知道有什么办法吗?

Anyway, I've found a workaround: Using proxyName and proxyPort properties in tomcat Connector configuration, you can tell Tomcat that is behind a proxy (in our case, Apache server) and that the "real" port for the clients is 80.

无论如何,我找到了一个解决方法:在 tomcat 连接器配置中使用 proxyName 和 proxyPort 属性,您可以告诉 Tomcat 位于代理(在我们的例子中是 Apache 服务器)后面,并且客户端的“真实”端口是 80。

Doing this change, the autogenerated soap:address contains the correct value.

执行此更改后,自动生成的 soap:address 包含正确的值。

References:

参考: