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

Ok supposing you have just deployed your Web Service application on JBoss EAP or WildFly. From the server logs you can see :

16:18:12,387 INFO  [org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean] (MSC service thread 1-6) Creating Service {http://www.jboss.org/jbossws/ws-extensions/wsaddressing}AddressingService from WSDL: WEB-INF/wsdl/AddressingService.wsdl
16:18:12,788 INFO  [org.apache.cxf.endpoint.ServerImpl] (MSC service thread 1-6) Setting the server's publish address to be http://localhost:8080/wildfly-jaxws-addressing/AddressingService
16:18:12,873 INFO  [org.jboss.ws.cxf.deployment] (MSC service thread 1-6) JBWS024074: WSDL published to: file:/home/francesco/jboss/wildfly-10.0.0.Final/standalone/data/wsdl/wildfly-jaxws-addressing-service.war/AddressingService.wsdl

This information informs us about the published address of the Web service which is set to : http://localhost:8080/wildfly-jaxws-addressing/AddressingService?wsdl

Besides server logs, there are other strategies to retrieve the Web service URL:

1) Use the Command Line Interface

By pointing to the deployment unit which contains the Web service, it is possible via CLI to retrieve the WSDL URL of it:

[standalone@localhost:9990 /] /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"
    }
}

 2) Use the Web Admin console

The above information is visible from the Management instruments of the application server. If you navigate to the Runtime upper tab of the Web console, and select the Web Services Subsystem:

web service wsdl jboss wildfly

How is the WSDL URL generated ?

You might however wonder how the WSDL URL is generated. Well the starting point is the Web service name, which is defined in the WSDL:

<wsdl:service name="AddressingService">

If you are coding Code first Web services, 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, the modify-wsdl-address property must be set 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.

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>

Related articles available on mastertheboss.com

JBoss web services

JAX-WS simplifies the development model for a web service endpoin

What is a Web Service One Way invocation?

JBoss recipe of the day

Asynchronous web services with JBoss WS

Developing rigorous and responsive web service client application

How to change the default Web Service deployment Port ?

JBoss recipe of the day

Using Axis Web Services with JBoss

Still not ready for JBoss WS ? if you don't have a JDK 1.5 compli

Invoking JBoss Web Services with Flex

Flex® is a free, open source framework for building highly in

Follow us on Twitter