|
By Richard Mah
Created on February 21, 2005
Updated on December 1, 2005
In this tutorial we look at using the WSDL Editor to create and modify
a WSDL file. We explore the basic functionality along with some of the
more advanced ones.
- Create a new project called "WSDL Example".
- Launch the new WSDL Wizard (File --> New --> Other --> XML
--> WSDL). Select "WSDL" under the "XML" folder and click on "Next".
- Enter "Employee.wsdl" as the name for the WSDL file and select
"WSDL Example" as the project where the WSDL should be created. Click
on "Next".
- The first two fields of the "Options" dialog page are used to set
the target namespace and prefix of the WSDL. For our example, use the
default values. (Figure 1).
Figure 1
The next option is the "Create WSDL Skeleton". If this option is
selected, the wizard will create a simple WSDL skeleton from which we
can quickly modify the WSDL as we see fit. We will discuss the contents
of the generated skeleton below.
If the "Create WSDL Skeleton" is selected, we are presented with
additional options to configure. The first is the protocol. From this
dropdown menu we can select either the SOAP or HTTP protocol. Next are
the Binding Options. The choices listed here will depend on the
protocol selected. Only Binding Options which apply to the selected
protocol will be displayed. The Protocol and Binding Options selected
here will be used to generate the Binding for the WSDL Skeleton.
For our example, use the default Protocol and Binding options (SOAP
Protocol and document literal Binding Option) and click on "Finish".
Below we see the generated WSDL skeleton (Graph View).
Figure 2
The graph view above displays the WSDL in an easy to read format.
The view is divided into several groups with each containing instances
of that particular element.
Selecting a WSDL element in the graph view also shows it's
relationship to the other elements by connecting arrow lines. For
example, if we select "NewOperationRequest" Part (Figure 2), arrow
lines will be drawn from the Port --> Binding Input --> Port Type
Input --> Part --> XML Schema Element.
1) Renaming WSDL Elements
Renaming a WSDL Element is done by right-clicking on the element and
selecting "Rename". Alternatively, rename can be done through the
properties view.
For our example, rename the Operation "NewOperation" to
"EmployeeInfoById". Notice the multiple renamings which occur. The
Operation is renamed along with it's associated Messages, Parts, and
XML Schema Elements. (Figure 3).
Figure 3
2) Creating a new WSDL Operation
To create an Operation, select the Port Type "Employee". Right-click
and select "Add Operation". The Add Operation dialog will appear. See
Figure 4
Figure 4
The dialog contains the option "Create default messages". Selecting
this option will create a new Operation along with the following
associated elements:
- Input and Output
- Two Messages with one Part each
- Two XML Schema Elements. One for each Part
Without the "Create default messages" option selected, only the Opeation along with an input and output will be created.
For our example, select the "Create default messages" option and type in "EmployeeInfoByName" as the name. Click on "Ok".
Notice the names used for the newly created WSDL and XML Schema objects.
3) Editing the Inline Schema
We shall use the XML Schema View to modify the inline schema. In the
"Types" group, double-click on the inline schema. The XML Schema View
will appear showing four XML Schema Elements. Follow the steps below to
edit the XML Schema:
- Create a Complex Type by right-clicking in the "Types" group and selecting "Add Complex Type".
- Double-click on the Complex Type to drilldown into it.
- Rename the Complex Type to "EmployeeInfo".
- Right-click on the Complex Type and select "Add Sequence".
- Select the newly created sequence and add three Elements by right-clicking and selecting "Add Element".
- Modify the newly created Elements so they appear like Figure 5.
Figure 5
- Move up from the Element view to the Schema view using the back
button located at the top.
- Select the Element "EmployeeInfoByIdRequest". In the properties view, change the Type from "string" to "integer".
- Double-click on the Element "EmployeeInfoByIdResponse" to drilldown into the Element.
- Rename the Element to "EmployeeInfo".
- In the properties view, change the Type from "string" to "EmployeeInfo" and click on "Ok". See Figure 6
Figure 6
- Move up from the Element view to the Schema view using the back button located at the top.
- Next, delete the Element "EmployeeInfoByNameResponse". Right-click on the Element and select "Delete".
- Move back from the Schema view to the WSDL view using the back button located at the top.
- We must now modify "EmployeeInfoByIdResponse" and
"EmployeeInfoByNameResponse" Parts to reference the renamed XML Schema
Element "EmployeeInfo". Right-click on the Part and select "Set
Element" --> "Existing Element..." from the context menu. In the
dialog, select the "EmployeeInfo" Element and click on "Ok". See Figure
7
Figure 7
3) Re-generating the Binding
The last step required is the re-generation of the Binding. The Binding
was originally based on the Operation generated by the wizard. But
since then we have modified and created a brand-new Operation.
Right-click on the "EmployeeSOAP" Binding and select "Generate Binding
Content...".
Select the "Overwrite existing binding information" option and click-on
"Finish". See Figure 8.
Figure 8
The finished WSDL file is shown in Figure 9.
Figure 9
Automatic binding generation is also available. The Bindings will be
regenerated to reflect the changes made to the Port Types when a Save
is executed. By default, this option is disabled but may be turned on
via the WSDL Preferences ("Window" --> "Preferences" --> "Web and
XML" --> "WSDL Files"). See Figure 10.
Figure 10
Now that we've finished editing the WSDL, you can save the file.
|