How to start cxf service on localhost but return e

2019-02-18 03:38发布

问题:

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.

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.

回答1:

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.



回答2:

Try @WebService(wsdlLocation="http://yourdesiredlocation"). Not sure if it will work.