Introduction to the WSDL Editor

From Eclipsepedia

Jump to: navigation, search


Introduction to the WSDL Editor
WTP 1.5.1

Image:WSDL_Tutorial_0.jpg

http://www.eclipse.org//webtools/images/wtplogosmall.jpg

WSDL - Web Services Description Language - is an XML based language for describing Web services and how to access them (binding protocol, message format, etc.). It enables one to separate the description of the abstract functionality offered by a service from concrete details of its description such as "how" or "where" that functionality is offered. The WSDL editor is a powerful tool makes it possible to create and edit WSDL files graphically, automating most of the tasks involved with these processes.


Example: creating a WSDL file

Let’s create a WSDL file for a simple Web service we’ll call “InternationalTime”. This Web service receives as a parameter a location composed of the name of a city and the name of a country, and returns its current time. To start creating the WSDL file, open the file menu and select new - other - XML - WSDL.

Image:WSDL_Tutorial_1.jpg




We’ll be prompted to type the name of the file to be created. In our example we’ll name the file “InternationalTime.wsdl”. After that click on the Next button to go to the next page. Accept the defaults on the WSDL Options page. It should look like the following:

Image:Wsdlwizardoptions.jpg




Click on the Finish button to close the dialog box. A WSDL skeleton will automatically be created, which gives us an excellent starting point for describing our Web service. The skeleton should look as follows:

Image:WSDL_Tutorial_2.jpg




Let’s set the name of the Web service operation to “getInternationalTime”. To do this, it suffices to double click on the operation title and type the new name as shown below.

Image:WSDL_Tutorial_3.jpg




Next we’ll specify the input and output formats of this service. To do so, we first click on the arrow that appears right next to the input operation:

Image:WSDL_Tutorial_4.jpg




This will open an Inline Schema editor: a new tab will appear on top of the editor indicating so:

Image:WSDL_Tutorial_5.jpg




In the Inline Schema Editor, we’ll set the type of the get InternationalTimeRequest element. In this particular case, given that the input parameter is a location composed by the name of a city and the name of a country, we’ll create a new complex type by right-clicking the InternationalTimeRequest element and selecting Set Type - New. In the New Type dialog box we select Complex Type and set its name to "Location". Next we add the elements "Country" and "City" of type String and set the kind attribute to "All". Once finished, the Location element should look as follows.

Image:WSDL_Tutorial_6.jpg




We now return to the WSDL editor main screen by clicking on its corresponding tab:

Image:WSDL_Tutorial_7.jpg




Next we set the format of the output in the same way we did for the input. We start by clicking on the arrow that appears right next to the output as follows. The Inline Schema editor will open. In it, we set the type of the getInternationalTimeResponse element by right-clicking it and selecting Set Type - Browse. Since our web service will return the time of a given location, we choose from the type list time and click on OK and save the changes made to the WSDL file. At this point we wont be needing the Inline Schema Editor any more, so we close it.
We are done ! from the WSDL editor main screen we can click on the “Source” tab located at the bottom of the screen to see the XML code that has been automatically generated.

Image:WSDL_Tutorial_8.jpg




Finally we have to make sure the WSDL file is valid. To do this, we right-click the file and select Validate.

Image:WSDL_Tutorial_9.jpg




In case there are any problems with the contents of the file, these will appear on the Problems window. If the Problems window is not visible in your workbench, you can show it by selecting from the main menu: Window - Show - View - Problems

More Examples

The previous example is intended to show just some of the basic operations that the editor offers. To view some of the more advanced options of the editor, we recommend exploring the sample WSDL files provided in the XML Example set. To access it, open the file menu and selection new – Examples. In the Wizard that appears, open the XML folder and select Editing and validating XML files. Then click on Next.

Image:WSDL_Tutorial_10.jpg




A new project with a set of files will be created. The sample WSDL file is located in the PhoneBanking and SpaceWarGame folders.

Image:WSDL_Tutorial_11.jpg