WSDL stands for Web Services Description Language. WSDL is used to describe web services and also known as Contract. It is the base building block to create a SOAP webservice in Contract-First Approach.
Creation of WSDL consist of following:
Schema Design
WSDL Design
In the below example, we are creating a WSDL which contain a single operation createCustomer. You can follow the similar approach to add more operation in the WSDL.
Schema Design
First of all, we will create a schema file to define the request, response and fault structure.
binding element has two attributes - name and type. The name attribute (you can use any name you want) defines the name of the binding, and the type attribute points to the port for the binding, in this case the “CustomerServicePort” port.
soap:binding element has two attributes - style and transport. The style attribute can be “rpc” or “document”. In this case we use document. The transport attribute defines the SOAP protocol to use. In this case we use HTTP.
operation element defines each operation that the portType exposes. For each operation the corresponding SOAP action has to be defined. You must also specify how the input and output are encoded. In this case we use “literal”.
Service
Defines the port and binding with the address where you want to expose your service.
Simple Object Access Protocol is a messaging protocol specification for exchanging structured information. Its purpose is to provide extensibility, neutrality and independence.
SOAP uses XML for its message format.
SOAP relies on application layer protocols such as HTTP, SMTP, TCP, UDP, or JMS for message negotiation and transmission.
SOAP consists of three parts
an envelope, which defines the message structure and how to process it
a set of encoding rules for expressing instances of application-defined datatypes
a convention for representing procedure calls and responses
SOAP building blocks
A SOAP message is an ordinary XML document containing the following elements:
Element
Description
Required
Envelope
Identifies the XML document as a SOAP message
Yes
Header
Contains header information
No
Body
Contains call, and response information
Yes
Fault
Provides information about errors that occurred while processing the message