如何在localhost上启动cxf服务但在wsdl中返回外部地址? [英] How to start cxf service on localhost but return external address in wsdl?
问题描述
我在apache后面使用cxf和jetty来通过soap公开web服务。目标是在所有情况下在 http:// localhost:9000 上启动jetty并拥有apache代理,但是自动生成的wsdl显示一个适合其运行环境的soap:地址(例如 http://api.testing.example .com , http://api.uat.example.com , https://api.example.com )。似乎生成的wsdl2java * Service类接受wsdl的URL,并且必须既作为开始的location,又作为soap:address中返回的字符串。这必须是可配置的,但不是很明显,所以建议值得赞赏。
I'm using cxf and jetty behind apache to expose a webservice via soap. The goal is to start jetty on http://localhost:9000 in all cases and have apache proxy to it, but have the autogenerated wsdl show a soap:address appropriate to the environment it's running in (eg http://api.testing.example.com, http://api.uat.example.com, https://api.example.com). It seems that the generated wsdl2java *Service class accepts a URL for the wsdl and that must serve as both the "location" to start at as well as the string returned in soap:address. This must be configurable, but it ain't obvious, so advice is appreciated.
更清晰一点 - 我将WsdlURL传递给构造函数通过Spring的Service类(到目前为止只有 http:// localhost:9000 有效)。我需要解决这个问题的解决方案是在cxf.cml,cxf-.xml,spring或其他配置文件中进行配置更改,而不是在代码中,因为此参数将根据其所在的环境而更改已经部署。
A little more clarity - I'm passing in the "WsdlURL" to the constructor of the Service class via Spring (so far only http://localhost:9000 works). I need the solution to this problem to be a configuration change either in cxf.cml, cxf-.xml, spring or some other config file, rather than in the code, since this parameter will change based on the environment to which it is being deployed.
推荐答案
jaxws:端点配置事物有一个publishedEndpointURL,如果指定了地址,它将被用来代替地址。知道servlet正确使用它,而不是100%肯定在码头上。他们分享了很多代码,所以它可以工作。
The jaxws:endpoint configuration thing has a "publishedEndpointURL" which is used instead of the address if it's specified. In know the servlet uses that properly, not 100% sure on the jetty. They share a lot of code so it MAY work.
这篇关于如何在localhost上启动cxf服务但在wsdl中返回外部地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!