Search code examples
javaweb-servicesmaven-2jax-wscxf

How to use root context as wsdl end point in CXF Web service


I had created web service with java classes generated from WSDL using CXF framework hosted using spring - web app on tomcat. my port binding is as shown below.

<wsdl:service name="ServiceManagement">
        <wsdl:port binding="tns:ServiceManagementSOAP" name="ServiceManagementSOAP">
            <soap:address
                location="http://localhost:8080/XXXXX/services/ServiceManagementSOAP" />
        </wsdl:port>
    </wsdl:service>
  1. I give the url http://localhost:8080/XXXXX/services.
  2. All the wsdl hosted on that server are shown on CXF service list
  3. When I click on individual operations. it opens up to give me wsdl, services/ServiceManagementSOAP?wsdl

As for as now everything went fine since I was using hosting it in my local machine. Now the problem is. when web service is hosted on different machine and click on individual wsdl in the CXF Service List,it gives me connection not found. When I verified I can find that Endpoint address is still http://localhost:8080/XXXXX/services/ServiceManagementSOAP. suppose instead of clicking on WSDL url. Give the WSDL url and replace localhost with IP address of the hosted machine it works fine.

So now the question is. doesn't CXF handle port binding itself by replacing the localhost with root context of web app. if it doesn't, is there ay solution to work it out. SO that when I port the web service to different machine it will automatically update the ip address.


Solution

  • I had the workaround, Since I use tomcat6 plugin to deploy the war file. When I give the ipaddress of target server(if its localhost, then 127.0.0.1) in url. Then IPAddress of the server is displayed in endpoint.

    Endpoint address: http://127.0.0.1:8080/xxxxx/services/YYYYY
    WSDL : {http://kp.com/aaaa/webservices/YYYY/}bbbb
    Target namespace: http://kp.com/aaaa/webservices/YYYY/
    

    Hence when you click on WSDL in points to corresponding server.

    However I could not find, how to do it when we deploy it from tomcat manager url