# 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

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