How do I know the WSDL URL of my Web Service ?

In this tutorial we will learn how to find the SOAP Web Service WSDL URL, so that you can quickly test your SOAP Web Service.

SOAP Web Service overview

Firstly, let’s deploy a sample SOAP Web Service on JBoss EAP or WildFly. If you inspect the server.log file, you will see that the Logger org.jboss.ws.cxf.metadata displays useful information about a Web Service:

How to find the WSDL of a Web service

This information shows us about the the SOAP Web Service Address and WSDL which corresponds to the address plus the.wsdl suffix. In our case it is http://localhost:8080/ee-ws-basic/AccountWS?wsdl

Besides server logs, there are other strategies to retrieve the SOAP Web Service URL. For example:

1) Use the Command Line Interface

Firstly, by pointing to the deployment unit which contains the SOAP Web Service, you can retrieve the WSDL URL with this CLI:

/deployment=wildfly-jaxws-addressing.war/subsystem=webservices/endpoint=com.demo.AddressingService:read-resource(include-runtime=true) 
{ "outcome" => "success", "result" => 
     { 
       . . . . 
       "wsdl-url" => "http://localhost:8080/wildfly-jaxws-addressing/AddressingService?wsdl" 
     } 
}

Besides, here is a quick tip to get the WSDL URL for all Web Services running on WildFly:

/deployment="*"/subsystem=webservices/endpoint="*":read-resource(include-runtime=true)
{
    "outcome" => "success",
    "result" => [{
        "address" => [
            ("deployment" => "ee-ws-basic.war"),
            ("subsystem" => "webservices"),
            ("endpoint" => "ee-ws-basic%3Acom.itbuzzpress.jaxws.ws.AccountWS")
        ],
        "outcome" => "success",
        "result" => {
            "average-processing-time" => 0L,
            "class" => "com.itbuzzpress.jaxws.ws.AccountWS",
            "context" => "ee-ws-basic",
            "fault-count" => 0L,
            "max-processing-time" => 0L,
            "min-processing-time" => 0L,
            "name" => "com.itbuzzpress.jaxws.ws.AccountWS",
            "request-count" => 0L,
            "response-count" => 0L,
            "total-processing-time" => 0L,
            "type" => "JAXWS_JSE",
            "wsdl-url" => "http://localhost:8080/ee-ws-basic/AccountWS?wsdl"
        }
    }]
}

As you can see, besides the WSDL URL, with the above commandyou can also collect the metrics for the Web Services including faults and processing time.

2) Use the Web Admin console

First, connect to the Web Console of the application Server. Next, navigate to the Runtime upper tab of the Web console, and select the Web Services Subsystem:

web service wsdl jboss wildfly

As you can see, the WSDL Url shows in the above element.

3) Look into the WSDL itself (for Top-Down Web Services)

If you are developing Top-Down Web services (also known as Contract-First Web Services), you can define the Contract Definition of your SOAP Web Service in a WSDL file. Within the WSDL, look out for the soad:address location element:

   <service name='ProfileMgmtService'>
      <port binding='tns:ProfileMgmtBinding' name='ProfileMgmtPort'>

         <!-- service address will be rewritten to actual one when WSDL is requested from running server -->
         <soap:address location='http://SERVER:PORT/jaxws-retail/ProfileMgmtBean'/>
      </port>
   </service>

The parameter location contains the WSDL URL for your Web Service. In our case, we rely on the default rewriting of the WSDL address with the actual server address and port, where the service has been deployed.

How is the WSDL URL generated ?

To answer this question, the starting point is the SOAP Web Service name, which shows up in the WSDL file:

<wsdl:service name="AddressingService">

If you are coding Code-first SOAP Web Service, you can define the Web service name through annotations as follows:

@WebService(
        portName = "AddressingPort",
        serviceName = "AddressingService")
public class AddressingService implements AddressingServiceWs {

//. . .
}

Now you know about the Service name. The host and port where the Service is exposed is a matter of configuration:

web sevices jboss wildfly wsdl

In practice, when exposing the SOAP Web Service, the application server performs an URL rewriting of the SOAP Address (contained in the WSDL), replacing the host name with the property wsdl-host and the port with wsdl-port.

Important ! In order for the rewriting to work, set the modify-wsdl-address property to true (By default it’s true). If this property is set to false the <soap:address> URL declared in the WSDL will be used instead.

Customizing the WSDL Path

Since JBossWS-CXF 5.0 it is possible to customize the Path of the WSDL by using a Sed-like syntax replacer. For example:

<subsystem xmlns="urn:jboss:domain:webservices:2.0">
            <modify-wsdl-address>true</modify-wsdl-address>
            <wsdl-path-rewrite-rule>s/regexp/replacement/g</wsdl-path-rewrite-rule>
            <!-- Other configuration -->
</subsystem>

Please notice that, in order to take effect, it is required to set the modify-wsdl-address property to true.

Rewriting the SOAP address using XML descriptors

Finally, you can use the WEB-INF/jboss-webservices.xml file to rewrite the SOAP address, Port or protocol to be exposed by your Web service. Here is an example;

<webservices version="1.2"
  xmlns="http://www.jboss.com/xml/ns/javaee"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://www.jboss.com/xml/ns/javaee">
  <property>
    <name>wsdl.soapAddress.rewrite.wsdl-host</name>
    <value>hostname</value>
  </property>
  <property>
    <name>wsdl.soapAddress.rewrite.wsdl-port</name>
    <value>8080</value>
  </property>
</webservices>

Where WildFly stores the WSDL ?

If you let JBoss/WildFly generate the WSDL (bottom-up strategy) a copy of the WSDL will be saved locally into the data folder of the application server, under the wsdl folder. For example:

data
├── kernel
│   └── process-uuid
├── timer-service-data
├── tx-object-store
└── wsdl
    └── ee-ws-basic.war
        └── AccountWSService.wsdl

Conclusion

This article was an extensive walk through the options to retrieve the WSDL URL and location for SOAP Web Service. This is a necessary step in order to be able to test SOAP Web Services. To learn more about it, continue reading here: How to test SOAP Web Services

Found the article helpful? if so please follow us on Socials