Skip to main content

skip to main content

developerWorks  >  WebSphere  >

Web Services Programming with WebSphere Studio Application Developer: Part 1 -- Web Services Discovery and Evaluation

developerWorks
Document options

Document options requiring JavaScript are not displayed


Learn and share!

Exchange know-how with your peers -- try our new Pass It Along beta app


Rate this page

Help us improve this content


Level: Introductory

Paul Pacholski (pacholsk@ca.ibm.com.), Worldwide Technical Sales Consultant for WebSphere Tools, IBM

18 Apr 2002

This article describes how to use IBM WebSphere Studio Application Developer to discover and evaluate Web services. You will learn how the Application Developer Web services tooling makes the discovery and evaluation of Web services quick and simple.

Introduction

There are many useful Web services available today from a multitude of UDDI Business Registries and other UDDI compliant repositories. The task of discovery and evaluation of Web services can be complex and often may require writing code. This deters many programmers from using Web services in Web applications. This article describes how to use IBM ® WebSphere® Studio Application Developer to discover and evaluate Web services. You will learn how the Application Developer Web services tooling makes the discovery and evaluation of Web services quick and simple.

The discovery and evaluation of a Web service with Application Developer requires four easy steps (actually three if you do not count the initial setup):

  1. Setting up WebSphere Studio Application Developer
  2. Connecting to UDDI compliant registry
  3. Discovering and importing the Web services into Application Developer project
  4. Testing the Web service

The only product used in this paper is IBM WebSphere Studio Application Developer, Version 4.0.3 for Windows®.

No familiarity with the basic operations of Application Developer is required to follow the procedures described below.



Back to top


Step 1. Setting up WebSphere Studio Application Developer

  1. Install WebSphere Studio Application Developer.
  2. Start WebSphere Studio Application Developer.
  3. Create a Web and EAR (Enterprise Archive) projects.

    We will now create a Web project which we will use to download WSDL files and conduct unit testing and evaluation of the Web services. We will also create an EAR project required to deploy our unit test Web application (Test Client) to WebSphere v4.0 Test Environment.

    1. Click Open Perspective Open Perspective icon, located on the vertical Perspective toolbar, to open Web Perspective.
    2. To create Web and EAR projects, from the main toolbar, click Create a Web project Create a Web Project icon.
    3. On the Define the Web project page enter WebServicesEvaluation for the project name and WebServicesEvaluationEAR for Enterprise Application project name. See Figure 1 below.
      Figure 1. Defining Web project
      Defining Web Project
    4. Click Finish to create the Web and EAR projects.


Back to top


Step 2. Connecting to a UDDI compliant registry

The UDDI Explorer tool in Application Developer enables you to discover or register a Web service in UDDI-complaint registries. Any UDDI V1 and V2 compliant repository can be accessed using UDDI Explorer. In this article, we will access the XMethods Web services repository. XMethods has a large collection of Web services from many providers. XMethods' UDDI V1 and V2 compliant interface allows inquiry and retrieval operations only.

  1. Launch IBM UDDI Explorer.

    1. Select the WebServicesEvaluation Web project.

      In the steps to follow, you will be importing the Interface WSDL file (of the Web services you will discover) into the root directory of the WebServicesEvaluation Web project.

    2. From the main menu select File => Import.
    3. On the Select page, select UDDI and click Next.
    4. In UDDI Import page, click Finish. This will launch the IBM UDDI Explorer tool.

      After a few seconds, you should see a Web browser window running the UDDI Explorer Web application. See Figure 2 below.


    Figure 2. IBM UDDI Explorer
    IBM UDDI Explorer
  2. Connect to XMethods UDDI business registry.

    1. Click on the UDDI Main link in the UDDI Navigator frame.
    2. In the Actions frame, enter XMethods for registry name and http://uddi.xmethods.net/inquire for Inquiry URL.
    3. Click Go. An XMethods entry will be added under the UDDI Main tree.
    4. Click on XMethods link in UDDI Navigator frame. See Figure 3 below.
      Figure 3. XMethods UDDI business registry
      XMethods UDDI Business Registry
    5. To save this link for future use, click on Add to favorites Add to favorites icon in the Actions frame toolbar.


Back to top


Step 3. Discovering and importing the Web services into Application Developer project

In this step, you will search for a Web service based on its English description.

Before we delve into the details of discovering a Web service, let's examine the three different ways you can discover Web services with the UDDI Explorer. The first one, Find Business Entities (as shown in Figure 4 below), is recommended when you know the business entity and you want know what Web services that business entity provides. The second one, Find Business Services, lets you find a Web service (and its interface WSDL file) by its English description. It searches the Web service descriptions in all registered business entities. Finally, Find Business Interface is equivalent to Find Business Services, except that it finds the Service (also known as the Binding) WSDL file, not the Interface WSDL file.

  1. Discover a Web service.

    Suppose we are interested in Web services that provides mortgage payment calculations and we do not know or do not care what the Web service provider is. With IBM UDDI Explorer the task of finding a Web service based on its description is simple. Let us use the Find Business Services function.

    1. Click on Find Business Services link in UDDI Navigator frame.
      Figure 4. Finding Business Service
      Finding Business Service
    2. In Actions frame, enter %mortgage for service Name and click Go (% is the UDDI search wild card character). Wait a few moments for UDDI Explorer to search the XMethods Web services repository and return the following results in the query results folder.
      Figure 5. Query Results
      Query Results

      One match was found: the Monthly Mortgage Payment Web service.

  2. Import Web service into Application Developer project.

    1. In the UDDI Navigator frame, click on Monthly Mortgage Payment link under query results folder.
    2. In Actions frame:

      1. Make sure the Web project is WebServicesEvaluation.
      2. Change the WSDL file from temp.wsdl to MortgagePayment.wsdl.
      3. Click Go to import it into Application Developer.


        Figure 6. WSDL Import Details
        WSDL Import Details


Back to top


Step 4. Testing the Web service

You have just downloaded the service WSDL file (MortgagePayment.wsdl) into the root directory of the WebServicesEvaluation project. See Figure 7 below.


Figure 7. Imported WSDL File
Imported WSDL File

In the next two easy steps you will generate a Test Client and evaluate the Monthly Mortgage Payment Web service to see if it fits your requirements.

1. Creating Web service Client

  1. From the Navigator pane, select the MortgagePayment.wsdl file, right-click and select New => Other.
  2. In Select window, select Web services from left pane and Web service client from the right pane and then click Next.
  3. In Web service Client window, select:

    1. Generate a sample check box.
    2. Launch the sample check box.

      Figure 8. Web service Client Wizard Settings
      Web Service Client Wizard Settings

      If you specify a different file every time you import a WSDL file, you do not need to check Overwrite files without warning.

  4. Click Finish. Wait for the Web services client wizard to exit; this may take a few moments.

Now let's examine what code was generated.

JavaTM Proxy class:


Figure 9. Java Proxy
Java Proxy

It is used in the Test Client Web application to interact with this Web service. You can use the Java Proxy class later on in your own code to invoke this Web service.

Test Client Web application:


Figure 10. Test Client
Test Client

You will use this generated Test Client Web application to test the Web service in the next step.

Server project with WebSphere Server Instance and Configuration:


Figure 11. WebSphere Server Instance and Configuration
WebSphere Server Instance and Configuration

This Server Instance and Configuration is used to run the Test Client Web application.

The name of the Java Proxy (MortgagePayment) and the subdirectory for the Test Client Web application were named using the WSDL file name specified in Step 3.2.b. This makes it possible to use the same Web project for downloading and testing multiple Web services!

2. Testing and Evaluating the Web service

Application Developer has switched to the Server Perspective, and the Test Client Web application generated by the Web services client wizard has been started for you. You are now ready to test and evaluate the Web service.


Figure 12. Web services Test Client
Web Services Test Client
  1. In the Methods pane, click on CalculatePayment link. This link represents the operation offered by this Web service.
  2. Now the Inputs pane shows the parts of the request message of the CalculatePayment operation. Enter the required input data as shown in Figure 13 below.

Figure 13. Web services Test Client - Input Pane
Web Services Test Client - Input Pane
  1. Click Invoke to invoke the CalculatePayment operation of this Web service. You should now see the results in the Results pane as shown in Figure 14 below.

Figure 14. Web services Test Client - Result Pane
Web Services Test Client - Result Pane


Back to top


Conclusion

IBM WebSphere Studio Application Developer makes discovery, evaluation and testing of Web services easy. The IBM UDDI Explorer tool enables the discovery and import of Web services registered in any UDDI V1 and V2 compliant Web services repositories. The powerful Web Service client wizard performs all programing tasks required to evaluate Web service, including a generation of a Test Client web application that can be used to unit test a Web service. Since the entire procedure can be accomplished in minutes rather than hours, Application Developer is an ideal tool when a large number of Web services needs to be evaluated.

A follow-on article (Web Services Programming with WebSphere Studio Application Developer - Part 2) will be published soon. It will discuss some common WSDL-related problems that you may encounter when testing a Web service, and introduce some techniques to overcome these problems.



About the author

Photo: Paul Pacholski

Paul Pacholski is a technical sales consultant supporting WebSphere development tools with special focus on Web services. You can reach Paul at pacholsk@ca.ibm.com.




Rate this page


Please take a moment to complete this form to help us better serve you.



 


 


Not
useful
Extremely
useful
 


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!



Back to top