简体   繁体   English

如何从使用Spring部署的JAX-WS Web服务WSDL更改自动生成的soap:地址

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

I have a webservice implementation generated using wsimport from a WSDL. 我有一个使用来自WSDL的wsimport生成的webservice实现。 This service is deployed in a Tomcat server in a Spring webapp. 此服务部署在Spring Webapp中的Tomcat服务器中。 The spring configuration file (only the webservice part) is like this 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. 问题是在生产中,我们有一个Apache Web服务器,这个服务器将请求重定向到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. 它也有效,但是当我们获得WSDL时,soap:地址仍然是localhost:8080,我们需要将它作为webservice的公共URL。

Any ideas? 有任何想法吗?

Thank you very much. 非常感谢你。

Well, I've found one solution: 好吧,我找到了一个解决方案:

It seems that JAX-WS generates this property automatically. 似乎JAX-WS会自动生成此属性。 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. 我发现其他webservice框架实现,允许用户通过硬编码属性中的url来改变它,但似乎JAX-WS没有。 Somebody knows if there is some way? 有人知道有没有办法?

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 Connector配置中使用proxyName和proxyPort属性,您可以告诉Tomcat在代理(在我们的例子中是Apache服务器)后面,并且客户端的“真实”端口是80。

Doing this change, the autogenerated soap:address contains the correct value. 执行此更改时,自动生成的soap:地址包含正确的值。

References: 参考文献:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM