Creating a WSDL file using Eclipse

Author: Biswajit Kalita

Introduction to WSDL:

WSDL stands for Web Service Descriptive Language. It is an XML based definition language used for describing the functionality of a SOAP based web service. WSDL describes how to access a web service, what operations it will perform etc.

So, as we have RAML for REST APIs, similarly, we have WSDL for SOAP APIs. While everyone knows how to create a RAML file using Anypoint Platform, many seem to struggle when it comes to creating a WSDL file from scratch. So, in this blog, we will learn how to create a WSDL file using Eclipse IDE.

Creating a Skeleton WSDL File: 

1. Let’s create a new project in your Eclipse IDE. Go to File → New → Project → Java EE → Utility Project

The option of creating a WSDL file is available in any type of Java Enterprise Edition project.

 Now provide a project name and hit finish.

2. To create the file, right-click on the project and go to New → Other → Web Services → WSDL file and hit next.

Provide a proper name to the WSDL file and hit next. We are creating an Employee.wsdl in this blog.

3. On the next page, we will have the option to change the Target namespace, Prefix, SOAP Binding, etc. By default, Target namespace will be ‘’. You can change it if you want. Let’s change it to ‘’. Let’s change the prefix to ‘emp’ and keep the binding default – document literal, and then hit finish. It will create a skeleton WSDL for us.

4. Now you can see two tabs at the bottom of the editor – Design and Source.

Source is the XML editor, while Design is the graphical editor. 

5. You can see that a basic skeleton WSDL has been created by default. 

Now let’s go to the Design and use the drag and drop format to edit our skeleton WSDL.

Adding Operations:

1. Similar to Methods in RAML / REST, we have Operations in WSDL / SOAP. You can see an operation named ‘NewOperation’ has been created by default. Double click on it and change its name to something more meaningful. We’ll change it to ‘GetEmployee’. 

2. Next, we have to define the input parameters required to call this operation and the output parameters or response expected from this operation. To add the input parameters click on the arrow next to it. It will open the inline schema on a separate tab. By default, the input parameter is ‘in,’ and the type is string. Let’s change the name of the parameter to ‘EmployeeId’.

3. Now let’s go back to the main wsdl and click on the arrow next to the output parameter. You can see by default that the parameter is ‘out’ and type is string. Let’s change it to ‘Name’. Now, to add a new element, right-click on (GetEmployeeResponseType) and go to Add Element. Let’s add Email with type string, Phone with type integer, Designation with type string, as shown below.

Adding Complex Types:

1. Let’s add one more element to the response (Address), which will be a complexType and not a simpleType. A simpleType element contains only text. It cannot have attributes and child elements. A complexType element can contain text, child elements, and attributes. Select the type as New and hit OK.

2. To edit the Address type, go to Outline on the right-hand side and expand Types.

3. Double click on AddressType and add elements to it.

Reusing Complex Types:

1. Let’s create one more ComplexType with the name EmployeeType. To do that, go to Types, right-click and Add Complex Type.

2. Add elements to EmployeeType as shown below.

3. Now, we will go back to GetEmployeeResponse and delete all the elements that we have added previously. Then we will just add one element and refer to its type as our newly created EmployeeType. To do that, select Browse from the drop-down list of type and then select EmployeeType.

4. Now let’s create another operation – Add Employee. To do so, go to the main wsdl, right-click on Employee and click on Add Operation.

5. Add input parameter to the Add Employee operation. For type, again select the EmployeeType.

So, the ComplexType – EmployeeType is being used as an input type to AddEmployee and as an output type for GetEmployee operation.

6. Now add the output parameter for the AddEmployee operation. We will simply add one element – ‘ResponseMessage’.

Making elements optional / required:

By default, all elements are required, that is  maxOccurs=”1″ and minOccurs=”1″. To make an element optional, right-click on it and go to Set Multiplicity and select 0..1 (Optional). Let’s make Designation optional.

Importing XSD into WSDL:

So far, we have defined all the elements inside the WSDL itself. But ideally, we should create separate XSDs for inputs and outputs of different operations. And then import those XSDs inside the WSDL. Let’s see how we can do the import.

1. Create an XSD file inside the project or paste one if you have it already created. Not required if your XSDs are uploaded on the server.

2. Go to Outline and right-click on Imports, and then Add import. Now go to Properties and provide the location of the XSD file.

3. We can also do it using the XML editor:



        <xsd:import namespace=”” schemaLocation=”EmployeeInput.xsd”/>



Or if the XSD is uploaded on the server:



        <xsd:import namespace=”” schemaLocation=””/>




Now, if you go to the source tab, you can see the entire WSDL that has been created. Also, in the Outline section, you can see all the different things that we have defined.

Remember that this is an abstract WSDL which is used on the server-side. You can import this WSDL into MuleSoft Anypoint Studio (or other similar tools) and do the actual implementation of the SOAP API. Then we can expose our API and share the concrete WSDL with the client. The client will use the concrete WSDL to consume our API.

That’s all we have for this blog. I hope I was able to show you how easy it is to create an abstract WSDL using Eclipse. If you have any questions, feel free to drop a comment. Thank you.

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.