This tutorial shows you how WebSphere ® Studio Application Developer 4.0.2 can access Web services files produced by Microsoft ® .NET tools. For more information on the differences between Application Developer and Microsoft's .NET tools, see Part 1 and Part 2 of the article How the IBM Web Services Development Environment and Toolkit Compares with Microsoft Visual Studio .NET .
Application Developer 4.0 provides tools for creating, publishing, discovering, and testing Web services. Differences in how IBM and Microsoft interpreted the Web Service Description Language (WSDL) and Simple Object Access Protocol (SOAP) specifications resulted in incompatibility between the initial release of Application Developer; and Web services created using Microsoft tools such as Visual Studio .NET. Although many of these issues have been resolved in Application Developer 4.0.2, a manual workaround may still be needed in order to publish these Web services to the IBM UDDI Test Registry. The difficulty arises when Microsoft tools generate one monolithic WSDL file per Web service, while the Application Developer UDDI Explorer expects interface and implementation elements to be in separate WSDL files. The workaround is to manually split the monolithic WSDL file into two pieces during the publishing operation.
This tutorial shows you how to use the Application Developer Web services tools to publish, discover, and test a Microsoft .NET based Web service (a mortgage payment calculator) in a simulated Business to Business (B2B) environment. The tutorial participant will play the following roles:
- The business that wants to publish their service (publisher role)
- The business that needs to use the service (discoverer and tester roles)
The Web service will be published to and discovered from the IBM UDDI Test Registry using the Application Developer UDDI Explorer. Once you discover the service and import it into Application Developer, you will generate a sample client using the Web Services Client Wizard and then test it.
- Application Developer 4.0.2.
- An Internet connection -- either direct, or through an HTTP proxy server whose settings are configured on the Application Developer Internet Preferences page.
- A user ID and password to the IBM UDDI Test Registry. IBM UDDI Test Registry registration and information .
- A basic knowledge of Web services, WSDL, UDDI, XML, and Application Developer 4.0 Web and server perspectives and associated tools.
Create the service provider's Web project
- Launch Application Developer 4.0.2.
- Create a new Web project called MortgagePmtProject.
- From the main menu, select File => New => Other to view the list of Wizards.
-
Select
Web
in the left pane followed by
Web Project
in the right pane and click
Next
. See Figure 1 below.
Figure 1. Selecting the Web Project Wizard from the List of Wizards
-
In the Web Project Wizard (see Figure 2 below), enter
MortgagePmtProject
in the Project name field and click
Finish.
Figure 2. Specifying MortgagePmtProject for the Web Project's name in the Web Project Wizard
A DefaultEAR EAR Project will also be created and appear as a peer of MortgagePmtProject in the Navigator tree view. See Figure 3 below.
Figure 3. MortgagePmtProject Web and DefaultEAR EAR Projects in the Application Developer Navigator Treeview of the Web Perspective
Preparing service interface and service implementation WSDL files
The Web service to be published is a mortgage payment calculator. Given an interest rate, loan amount, and amortization period in months, the service returns the required monthly payment. Before the Web service can be published with the Application Developer UDDI Explorer, its WSDL files must be accessible via HTTP. This service's WSDL description is available via HTTP at http://www.vbws.com/services/MortgagePmt.asmx?WSDL . This is an XML compliant file. As mentioned earlier, the Application Developer UDDI Explorer cannot handle a monolithic WSDL file. Instead, the WSDL description must be separated into a service interface document and a service implementation document. The differences between these two documents are described in more detail in the section WSDL document types and Figure 2 of the article Understanding WSDL in a UDDI registry, Part 1 .
The WSDL service interface document contains the following elements: types , import , message , portType , and binding , while the WSDL service implementation document has import and service . An examination of the Web service's WSDL reveals the following elements: types , message , portType , binding , and service . This document falls under neither category, but it contains enough information to be split into the two required files.
-
Open an external Web browser and navigate to
http://www.vbws.com/services/MortgagePmt.asmx?WSDL
-
In the browser, select
File => Save As
and save this file on your local file system under the default name of MortgagePmt . The file will be saved in the selected directory as
MortgagePmt.asmx. From here on, the file is assumed to have the full path namex:\MortgagePmt.asmx. This file is included in the attached archive. Open this file in a text editor.
- Open a new instance of a text editor and create a new document. Type the following text:
<?xml version="1.0" encoding="utf-8"> </definitions>
Leave a blank line between the two tags. From the text editor instance containingx:\MortgagePmt.asmx, select everything between the two tags above minus the<service></service>section and copy this into the blank line in the new file. This new file represents the WSDL service interface document. Save this file asx:\MortgagePmt-interface.wsdl. This file has been included in the attached archive. - Open a new instance of a text editor and create a new document. Type the following text:
<import namespace="http://tempuri.org/" location="http://localhost:8080/MortgagePmtProject/ wsdl/MortgagePmt-interface.wsdl"/>
Leave a blank line between the two tags. From the text editor instance containingx:\MortgagePmt.asmx, copy the<definitions>tag followed by the<service></service>section into the blank line in the new file. Between the<definitions>and<service>tags, add the following tag:
<import namespace="http://tempuri.org/" location="http://localhost:8080/MortgagePmtProject/ wsdl/MortgagePmt-interface.wsdl"/>
This line imports the service interface file created in step 3. The location attribute of the import tag is an HTTP URL using port 8080. This port should be changed to another free port if 8080 is in use. This URL will be made live and valid in the upcoming steps. The new file represents the WSDL service implementation document. Save this file as
x:\MortgagePmt-service.wsdl. This file is included in the attached archive. -
Import
x:\MortgagePmt-interface.wsdlandx:\MortgagePmt-service.wsdlfiles into MortgagePmtProject created earlier in Application Developer: - In Application Developer, expand MortgagePmtProject in the Navigator tree view.
- Select the webApplication folder.
- From the main menu, select File => Import to view the list of Import Wizards.
-
Select
File System
as shown in Figure 4 below and click
Next
to proceed to the Import from File System Wizard.
Figure 4. Selecting the Import from File System Wizard from the list of Import Wizards
- In the Wizard, select Browse to open the Browse dialog, then select x: and click OK .
- In the Wizard, an x: folder should appear in the left tree view. Select it to display the list of files in the right pane.
-
Select the files
MortgagePmt-interface.wsdlandMortgagePmt-service.wsdl. - The Folder: field in the middle of the Wizard specifies the import destination. Change this to:
MortgagePmtProject/webApplication/wsdl
Figure 5 below shows the Import from File System Wizard with the Browse button, the WSDL files selected, and the correct destination folder specified.
Figure 5. Import from File System Wizard with the WSDL files selected and the correct destination folder
-
Click
Finish
to complete the import.
- Create and launch a server to host the WSDL files:
-
If a Server Perspective is not present, create one by selecting
Perspective=> Open=> Other
. In the Select Perspective dialog, select
Server => Finish
as shown in Figure 6 below. The workbench will now display the Server Perspective.
Figure 6. Creating a Server Perspective from the Select Perspective Dialog
-
Create a new Server project along with an instance and configuration in the Server Perspective. Select
File => New => Server Instance and Configuration
. In the Create a New Server Instance and Configuration Wizard, type
WSDL Server
for the Server name and
Servers
for the Folder, as shown in Figure 7 below. In the Server instance type
tree view
, expand WebSphere Servers and select
WebSphere v4.0 Test Environment
. Click
Next
and confirm that a server and configuration should be created. When the next page opens, verify that the HTTP port number is 8080. You will need to use a different port if 8080 is already in use (see step 4). Finally, click
Finish
to complete this task.
Figure 7. Creating the Server Instance and Configuration
-
If the Server Configuration view is not present in the Server Perspective, create it by selecting
Perspective => Show View => Server Configuration
. In this view, expand the Server Configurations folder, right-click
WSDL Server
, and from the pop-up menu, select
Add Project => DefaultEAR
. Figure 8 below shows the Server Configuration view with its nodes fully expanded after these operations.
Figure 8. Server Configuration view with nodes fully expanded
-
To start up the server, right click
WSDL Server
in the Servers view. (If it's not available, select
Perspective => Show View => Servers
to view its pop-up menu and then select
Start
). During startup, the Processes and Console views may be opened and overlaid on Servers. To switch between these views, click the tabs at the bottom. Figure 9 below shows these tabs with the Servers view selected. The figure also shows that WSDL Server has completed its startup, as indicated by the Status column.
Figure 9. Selected Servers View showing the highlighted bottom tab and the status of WSDL Server
- Verify that the URLs for the WSDL files are valid by opening a browser and navigating to the following URLs:
http://localhost:8080/MortgagePmtProject/wsdl/MortgagePmt-interface.wsdl
http://localhost:8080/MortgagePmtProject/wsdl/MortgagePmt-service.wsdl
These URLs assume that port 8080 was used in steps 4 and 6. Replace this number with the actual port number if necessary.
Publishing the Web service to the IBM UDDI Test Registry
The UDDI Explorer publishes a Web service to a UDDI Registry as a UDDI business service, which contains a pointer to the WSDL service implementation document (the WSDL URL). All UDDI business services must be associated with a UDDI business entity (the provider of the service). More information on the UDDI standard can be found on the UDDI Web site . The following procedure can be used to publish both the business entity and the Web service:
-
Select
File => Export
to view the list of Export Wizards. Select
UDDI
from this list, as shown in Figure 10 below, and select
Next => Finish
.
Figure 10. Selecting the UDDI Export Wizard from the list of Export Wizards
-
In the UDDI Explorer, select the
IBM Test Registry
node in the UDDI Navigator tree view on the left. The properties and actions for this node will be displayed in the Actions pane in the upper right.
-
In the Actions pane toolbar, select the
Publish Business Entity
action (represented by
). Before any write operations against the IBM UDDI Test Registry are allowed, you must log in. Consequently, the Login page opens. Fill in the User ID and Password fields with valid entries, replacing the examples shown in Figure 11 below, and click
Go
.
Figure 11. Logging in to the IBM UDDI Test Registry using the Application Developer UDDI Explorer
-
On successful login, the Publish Business Entity page will open. Type
MortgageBus
for the Name field. Because other users may use the same business entity name, add an identifier to make this MortgageBus more unique. Click
Add
in the Identifiers table to add an identifier. The page should reload with a new row containing two fields in the Identifiers table. For the key name and key value fields, enter userid and the actual user ID used to login in the previous step, respectively. Figure 12 below shows the completed page with an example user ID of abc. Finally, click to publish the business entity.
Figure 12. Publishing the MortgageBus UDDI Business Entity
-
Once the business entity is published, it will appear in the UDDI Navigator tree view on the left as a child of the IBM Test Registry node. Select this business entity (MortgageBus) to display its properties and actions in the Actions pane in the upper right.
-
In the Actions pane toolbar, select the
Publish Business Service
action (represented by
) to load the publish form. The only field you must complete in this form is URL for WSDL Implementation file, which is marked by a red asterisk as shown in Figure 13 below. Click
Browse
. In the Workbench WSDL Browser dialog, select
MortgagePmtProject
and
http://localhost:8080/MortgagePmtProject/wsdl/MortgagePmt-service.wsdl
in the Web Project and WSDL URL drop-down lists, respectively, as shown in Figure 14 below. Click
Go
to accept the entries and close the window. Verify that the WSDL URL selection has been successfully transferred to the URL for WSDL Implementation file field in the Publish Business Service form, and then click
Go
to publish the business service.
Figure 13. Publish Business Service form with the red asterisk showing the requirement of the URL to the WSDL implementation file
Figure 14. Workbench WSDL Browser Dialog with MortgagePmtProject and the WSDL URL selected
- To verify that the business service was successfully published, ensure that a new node, MortgageService, is added as a child of the MortgageBus node in the UDDINavigator tree view on the left. Figure 15 below shows the results of this section.
Figure 15. UDDI Navigator tree view after successfully publishing the Business Entity and Service
Discovering the Web Service and importing the WSDL into Application Developer
Using Application Developer, the business that intends to use the mortgage payment calculator Web service can generate the necessary proxy and a sample test client from the WSDL Service Implementation file or even with just its URL. The UDDI Explorer can locate the UDDI Business Service in the IBM UDDI Test Registry. From this object, the UDDI Explorer uses the pointer to the WSDL Service Implementation file to download the file into an Application Developer Web Project. The following steps simulate this process.
-
In the UDDI Navigator pane on the left side of the UDDI Explorer, select the
Find Business Entities
child of the IBM Test Registry node. The Actions pane on the right side of the UDDI Explorer will load the forms necessary to query the IBM Test Registry for UDDI Business Entities.
-
In the Actions pane toolbar, select the
Find Business Entities by Identifier
action (represented by
). When the Actions pane finishes loading the Find Business Entities by Identifier form, change the contents of the Name of this query field from query results to
Q1
. Click
Add
in the Identifiers table to add an identifier. The page should reload with a new row containing two fields in the Identifiers table. For the key name and key value fields, enter userid and the actual user ID specified in step 4 of the previous section. Figure 16 below shows the completed page with ABC as the user ID. Finally, click
Go
to initiate the search.
Figure 16. Find Business Entities by Identifier form with query criteria
-
If the search is successful, a node named Q1 is added as a child of the IBM Test Registry node in the UDDI Navigator pane on the left side of the UDDI Explorer. Under this new node, a business entity node named MortgageBus should be added as well. This represents the search result. Expand this node and select the Find Business Services child node to load its properties and actions into the Actions pane in the upper right.
-
In the Actions pane toolbar, click the
Find All Business Services
action (represented by the image
). After the form loads, change the contents of the Name of this query field from query results to
Q2
as shown in Figure 17 below and click
Go
to perform the search.
Figure 17. Find All Business Services form with query criteria
- A successful search will result in a query node named Q2 added as a child of MortgageBus with the business service MortgageService as its child representing the search results. Figure 18 below shows the UDDI Navigator tree view at this point.
Figure 18. UDDI Navigator treeview after successfully discovering the Business Entity and Service
-
Return to Application Developer and create a new Web Project named MortgagePmtClientProject. Follow the instructions above for creating the service provider's Web Project, MortgagePmtProject.
-
Select the
MortgageService
node to load its properties and actions into the Actions pane in the upper right. In the resulting Actions pane toolbar, select
Import to workbench
(represented by
). In the resulting form, select
MortgagePmtClientProject
in the Web Project drop-down, leave the contents of the WSDL file field,
MortgagePmt-service.wsdl, as shown in Figure 19 below, and click Go . The WSDL file will be downloaded asMortgagePmt-service.wsdlinto the root directory of the MortgagePmtClientProject Web Project, as shown in Figure 20 below.
Figure 19. Import WSDL to workbench form for importing MortgagePmt-service.wsdl into the MortgagePmtClientProject Web Project
Figure 20. Application Developer Navigator with the imported MortgagePmt-service.wsdl file selected
Testing the Web service in Application Developer
The Application Developer Web Service Client Wizard can generate a proxy and sample for quick testing of a Web service. The input to this procedure is either a WSDL service implementation file or a URL to the same. This section covers the first case, since the WSDL service implementation file was downloaded in the previous section.
-
Expand the MortgagePmtClientProject Web Project in the Navigator tree view in Application Developer and select
MortgagePmt-service.wsdl, as shown in Figure 20 above. Right-click the object and select New => Other from the pop-up menu to view a list of Wizards.
-
In the left pane of this Wizard, select
Web Services
. The right pane should then list various Wizards associated with Web Services. From this pane, select
Web Service client
, as shown in Figure 21 below. Click
Next
to display the Web Services Client Wizard.
Figure 21. Selecting the Web Service Client Wizard from the list of Wizards
-
In the resulting Wizard, ensure that
MortgagePmtClientProject
is selected in the Web Project drop down. Also, select the following check boxes:
Generate a proxy, Generate a sample, Launch the sample
,
Overwrite files without warning,
and
Create folders when necessary
, as shown in Figure 22 below. Click
Finish
to continue.
Figure 22. Web Service Client Wizard with selections
-
The sample will be launched in a Web browser (either embedded in Eclipse or outside of Eclipse, depending on user preferences and platform). The sample contains three panes: Methods, Inputs, and Results as shown in Figure 23 below. In the Methods pane, select the
MortgageCalculation
link.
-
The Inputs pane should change to show three fields: InterestRate, NumberofMonths and LoanAmount, along with the buttons Invoke and Clear. Enter
10
,
12
, and
1000
for the InterestRate, NumberofMonths, and LoanAmount respectively.
-
Click
Invoke
to execute the Web service with these three parameters. The result of running the Web service is displayed in the Results pane. A monthly payment of 87.92 should be displayed, as shown in Figure 23 below.
Figure 23. Sample Web Service Client after testing the Mortgage Payment Web Service
Occasionally, the IBM UDDI Test Registry is unavailable during maintenance. At those times, login, discovery, and publication operations will time-out and fail. If that happens, try the operations again later. Further information about the IBM UDDI Test Registry .
This tutorial showed you how to use the Application Developer Web Services wizards and tools to publish, discover, and test a Web service produced using Microsoft .NET tools. The tutorial included the steps required for the Application Developer UDDI Explorer to handle monolithic WSDL files. With this workaround in place, the Application Developer Web Services Wizards and tools greatly simplified the publishing, discovery, and testing of the Web service.
| Name | Size | Download method |
|---|---|---|
| archive.zip | 3 KB | FTP |
Information about download methods
Yen Lu is a software developer on the WebSphere Studio Application Developer Web Services Tools team at the IBM Toronto Lab. He is primarily responsible for development of the UDDI Explorer. He can be reached at yenlu@ca.ibm.com.




