Learn about WSDL file in SOAP Web Service

The WSDL file is a file that defines the information needed so that we can build a SOAP Web Service. In this tutorial, I will show you guys the details about the contents of this WSDL file.

First, let’s take a look at an example about the contents of a WSDL file:

As you can see, a WSDL file is defined starting with a root tag named <definitions> with multiple namespace declarations to be used in the WSDL file. In these namespaces, note the namespace xmlns:soap= “http://schemas.xmlsoap.org/wsdl/soap/”, which is the namespace that defines the SOAP Web Service version.

There are currently two versions of SOAP Web Service:

  • In SOAP 1.1, the namespace value will begin with “http://schemas.xmlsoap.org/soap/”.
  • For SOAP 1.2, the value will start with “http://www.w3.org/2003/05/soap-envelope”.

Of course, version 1.2 will be better than version 1.1. 😀 But in my example, I am using SOAP version 1.1.

Within the <definitions> tag, you will see the WSDL file defining the following child tags:

The first child tag is <types>, which will contain an XML Schema definition, defines the data types of the SOAP message that the client sends to the Web Service server. Thus, our Web Service can validate the content of the SOAP message according to the definition defined by the WSDL file.

In the above example, I have defined the data types for the <hello> and <helloResponse> tags in the SOAP message.

Next, you will see one or more <message> child tags that define the SOAP messages that our SOAP Web Service will process. You will see that each SOAP message will map to the types of data we have defined in the <types> tag.

Next, you’ll see that it’s a <portType> child tag. In a WSDL file, there is only one <portType> tag, essentially for defining SOAP Web Service interfaces, including operations along with mapping messages. An operation will include the message for the input (client request message) and the message output (response message returned to the client) and the message if the error occurred. These messages will be defined in the <message> tag that I said above.

In the above example, we defined an operation with the input message hello and the output message helloResponse defined in the two <message> tags of the WSDL file.

The near last child tag in the <definitions> tag is the <binding> tag. This tag defines the implementation of our SOAP Web Service, including transport protocol (HTTP), service style and SOAP version. We can define multiple <binding> child tags, depending on the number of transport protocols we want the SOAP Web Service to support.

The last child tag you can see is the <service> child tag. This tag will take all the definitions in the above tags to define a service endpoint, which defines the URL the client will be able to access.

Within this <service> child tag, you can see in the example above that it also defines one or more <port> child tags. With:

We have only one child <portType> tag, so the number of <port> tags depends on the number of <binding> tags we have defined above.

 

Add Comment