# How to create a WSDL file

## Introduction

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.

### XML Definition

Create a file of .xsd extension, in this case we are using customer-service.xsd

## WSDL Design

### Definitions

Create a file of .wsdl extension, in this case we are using customer-service.wsdl

### Schema Import

Import the schema which we have created in above example.

### Messages

Defines the data elements for each operation

### PortType

Describes the operations that can be performed and the messages involved.

### Binding

Defines the protocol and data format for each port type

• 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.

<wsdl:service name="CustomerService">
<wsdl:port name="CustomerServicePort" binding="tns:CustomerServiceBinding">
</wsdl:port>
</wsdl:service>


You can download the WSDL and XSD file for your reference

# SOAP - Simple Object Access Protocol

## What is SOAP ?

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
Body Contains call, and response information Yes
Fault Provides information about errors that occurred while processing the message No

### Fault Format

###### Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×