Web Service on OpenShift

2019-08-30 02:26发布

问题:

I have deployed a web service on OpenShift by annotating a class with @WebService and a public method with @WebMethod. Then, I deployed the class in a WildFly8 container and the server started the service. In order to be able to access the WSDL file I had to create a file "jboss-web.xml" inside the WEB-INF folder and change the context-root.

Now I am able to access the WSDL file, but not the service itself. The problem is in this line of the wsdl file:

<wsdl:service name="PlotterService">
    <wsdl:port binding="tns:PlotterServiceSoapBinding" name="PlotterPort">
      <soap:address location="http://127.8.173.1:8080/Plotter"/>
    </wsdl:port>
</wsdl:service>

The address location is set to an internal IP and should be replaced with the URL of my application. How can I do that? The only file I am able to modify is the class that I annotated at the beginning.

回答1:

I managed to solve this:

Openshift does not have Web services setup by default, so we need to modify the server configuration. To do this open .openshift/config/standalone.xml (this file may be hidden) in an editor and make the following additions:

If the webservices subsystem is not configured as below under the element, copy the following and replace the webservices subsystem to enable and configure Web Services:

<subsystem xmlns="urn:jboss:domain:webservices:1.1">
    <modify-wsdl-address>true</modify-wsdl-address>
    <wsdl-host>${env.OPENSHIFT_APP_DNS}</wsdl-host>
    <wsdl-port>80</wsdl-port>
    <endpoint-config name="Standard-Endpoint-Config"/>
    <endpoint-config name="Recording-Endpoint-Config">
    <pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
        <handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
    </pre-handler-chain>
    </endpoint-config>
</subsystem>