Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Creation of web services with WebSphere Application Server V7 and testing with Rational Service Tester or Rational Performance Tester

With SOA extension using stubbing technology

Luc Auvray (luc.auvray@fr.ibm.com), Software Quality Engineer Team Lead, IBM
Luc Auvray is an IBM software quality engineer and team lead in the Rational Toulouse development lab, in France. He currently works on IBM Rational Test RealTime, IBM Rational Service Tester for SOA and Performance Tester in the System Verification Team.

Summary:  IBM Rational Performance Tester SOA extension (RPT SOA) and IBM Rational Service Tester (RST) are used to run performance testing and functional testing on their Web based applications. The goal of this document is to explain how to test a Web Service designed for IBM WebSphere Application Server 7.0 using IBM Rational Application Developer and IBM Rational Service Tester 8.x or IBM Rational Performance Tester with SOA extension.

Date:  25 May 2010
Level:  Intermediate PDF:  A4 and Letter (2677KB | 60 pages)Get Adobe® Reader®
Also available in:   Korean

Activity:  10897 views
Comments:  

Introduction

The goal of this article is to explain how to test a Web Service designed for IBM WebSphere Application Server 7.0 using IBM Rational Application Developer and IBM Rational Service Tester 8.x or IBM Rational Performance Tester with SOA extension.

This document will demonstrate:

  • How to create a Web Service (invoker) with Rational Application Developer;
  • How to create a stub of a Web Service with Rational Application Developer which is call in a first step;
  • How to test a Web Service calling a stubbed Web Service with Rational Service Tester or Rational Performance Tester SOA extension.

Prerequisites

Before following the instructions in this article, you must install the following products:

  • Rational Application Developer 7.5.2 (minimal version)
  • WebSphere Application Server 7.0
  • Either Rational Service Tester 8.1.0.3 (minimal version) or Rational Performance Tester 8.1.0.3 with the SOA Extension

Creation of two web services with Rational Application Developer

To illustrate this example, we will create two web services:

  1. A quotation service: this is the web service that will be replaced with a stub. This service provides a quotation rate for each market.
  2. An intermediate invoker service: this is the web service under test, which uses the quotation service to select the best quotation among several markets.

In addition, you will need a client that can call the invoker service.

Creation of quotation web service to stub

  1. Open Rational Application Developer:
    Start > All Programs > IBM Software Delivery Platform > IBM Rational Application Developer 7.5 > IBM Rational Application Developer
  2. Open the J2EE Perspective:
    Click Windows > Open Perspective > Other > Java EE
    When prompted, specify a workspace location.
  3. Create a new dynamic Web project and then create a new WSDL File:
    File > New > Dynamic Web Project

Figure 1. New Dynamic web project
New Dynamic web project
  1. Select WebSphere Application Server 7.

Figure 2. Selection of runtime application
Selection of runtime application
  1. Click Finish.
  2. Enter the Project name and target runtime such as on next figure.

Figure 3. Project name setting
Project name setting
  1. Click Finish.
  2. Create a new WSDL file
    File > New > Web Services > WSDL

Figure 4. Create a new WSDL file
Create a new WSDL file
  1. Click Next.
  2. Specify a file name, for example: Quotation1.wsdl

Figure 5. Fill the WSDL file name
Fill the WSDL file name
  1. Click Next.

Figure 6. Attributes selection for the new WSDL
Attributes selection for the new WSDL
  1. Click Finish.
  2. Use the WSDL editor to create the following WSDL.
    Replace the name of the operation NewOperation with ProvideQuotation1 and switch to View > Advanced.

Figure 7. Update name of operation
Update name of operation
  1. Click on the arrow to specify the input data and define following input elements:

Figure 8. Data for input parameter ProvideQuotation1
Data for input parameter ProvideQuotation1
  1. Click the Output value arrow to specify the output data.

Figure 9. Data for output parameter ProvideQuotation1Response
Data for output parameter ProvideQuotation1Response

You have now defined the web service that you want to stub. We will define now the web service invoker in next section.

Creation of the web service for invocation

You can use the existing quotation web service to create another web service that will be used to invoke it.

  1. Create a new dynamic web service named: QuotationInvoker

Figure 10. Creation of new dynamic Web project for invoker
Creation of new dynamic Web project for invoker
  1. Click New to create a new EAR project.
    Specify the project name, for example: QuotationInvokerWebServiceEAR

Figure 11. Specification of the project name for invoker
Specification of the project name for invoker
  1. Click Finish.

You should see the following window:


Figure 12. Summarize of new dynamic Web project creation
Summarize of new dynamic Web project creation
  1. Click Finish.
  2. In the QuotationInvoker project, create a new WSDL file with the name:
    QuotationInvoker.wsdl File > New > Web Services > WSDL

Figure 13. Creation of new WSDL file
Creation of new WSDL file
  1. Click Next.
  2. Change the target namespace to the following value:

Figure 14. Specification of target namespace
Specification of target namespace
  1. Click Finish.
  2. Specify the Web Service WSDL as in the following diagram, with an operation named: GetBestQuotation.

Figure 15. Update operation name with GetBestQuotation
Update operation name with GetBestQuotation
  1. Define the Input parameter: Define a String for the endpoint. This endpoint value is used for providing the endpoint that the web service will use.

Figure 16. Definition of input parameter
Definition of input parameter
  1. Define the output value returns two values:
    place_market
    quotation

Figure 17. Definition of output parameter
Definition of output parameter
  1. Select the WSDL and generate the skeleton java code: Right-click > Web services > Generate Java Bean Skeleton
    Ensure that enabled web service runtime is: IBM WebSphere JAX-RPC Enable Publish the Web Service

Figure 18. Java skeleton generation for the invoker
Java skeleton generation for the invoker
  1. Click Next twice.

Figure 19. Final step for publication
Final step for publication
  1. Click Finish.

The following code is generated:


Figure 20. Generated code for the skeleton
Generated code for the skeleton

Creation of a client for the QuotationWebService1 web service to call

  1. You can use the QuotationWebService1 Web Service to generate a dedicated client for the service.
    To do this, you can generate a client from the Quotation1.wsdl file.
    To generate the skeleton: right click the WSDL file and select Web Service > Generate Client
    Copy-paste the code into the Web Service invoker.

Figure 21. Generation of client for Quotation1
Generation of client for Quotation1
  1. Ensure that Web Service runtime is set to IBM WebSphere JAX-RPC.

Figure 22. Check Web Service runtime
Check Web Service runtime
  1. Click Finish.
  2. This generates the Java source code:

Figure 23. Java code generated
Java code generated

Populating and using the web service invoker

  1. In the QuotationInvoker project src folder, copy-paste the org.example.www package source code from QuotationWebService1 to obtain the following result in the invoker:

Figure 24. Copy-Paste code into the invoker
Copy-Paste code into the invoker
  1. Replace the implementation code in QuotationInvokerSOAPImpl with the following code:

Listing 1. QuotationInvoker implementation

import java.rmi.RemoteException;

import org.example.www.Quotation1_PortTypeProxy;

public class QuotationInvokerSOAPImpl implements 
        org.QuotationInvoker.www.QuotationInvoker_PortType{
    public void getBestQuotation(java.lang.String endP, 
            javax.xml.rpc.holders.StringHolder place_market, 
            javax.xml.rpc.holders.DoubleHolder quotation) 
            throws java.rmi.RemoteException {
        
    	// Display on the console
    	System.err.println("endpoint : " + endP);
    	Quotation1_PortTypeProxy proxy = new Quotation1_PortTypeProxy();
    	proxy.setEndpoint(endP);
   
		double quoteNY = 0.0 ;
		double quoteParis = 0.0 ; 
		try {
	    	System.err.println(">>>");
	    	quoteNY = proxy.provideQuotation1("New York", "gold") ;
	    	System.err.println("quote New York= " + quoteNY);
	    	quoteParis = proxy.provideQuotation1("Paris", "gold") ;
	    	System.err.println("quote Paris= " + quoteParis);
		} catch (RemoteException e) {
			// NOP
			e.printStackTrace();
		}
    	
    	// Computation of best quote
		if (quoteNY > quoteParis)
		{
			place_market.value = "New York";
			quotation.value = quoteNY;
		}
		else
		{
			place_market.value = "Paris";
			quotation.value = quoteParis;			
		}
		
		}
    }

Get the QuotationInvoker.wsdl file for testing

  1. Copy the QuotationInvoker.wsdl file from the Rational Application Developer workspace l to a temporary directory, for example: C:\wsdl

Figure 25. Copy of QuotationInvoker.wsdl file
Copy of QuotationInvoker.wsdl file
  1. Copy the WSDL file of the Web Service that you want to stub into the same temporary directory for example: C:\wsdl

Figure 26. Copy wsdl file Quotation1.wsdl
Copy wsdl file Quotation1.wsdl

Preparation of the stub with IBM Rational Service Tester or with IBM Rational Performance Tester SOA Extension

The section demonstrates how to stub the call to the Web Service proxy.provideQuotation1 in Rational Service Tester because the associated java code has not been implemented yet.

Project creation on RST or RPT SOA extension

  1. Start Rational Service Tester or Rational Performance Tester with the SOA extension.
  2. Start > All Programs > IBM Software Delivery Platform > IBM Rational Service Tester > IBM Rational Service Tester – Full Eclipse

Figure 27. Start of Rational Service Tester
Start of Rational Service Tester
  1. Create a service test project
    File > New > Service Test Project

Figure 28. Creation of new Service Test project
Creation of new Service Test project
  1. Click Finish.
  2. At this point, Cancel the creation of a new test from recording.

Figure 29. Cancel creation of new recording
Cancel creation of new recording

Creation of a stub for Quotation Web Service

Now it is required to write the stub of the Web ServiceQuotation1 to simulate the behaviour of the operation ProvideQuotation1

  1. Click on Create a Service Stub icon

Figure 30. Service Stub icon
Service Stub icon
  1. Then click the Import From File button.

Figure 31. Importation of file for stubbing
Importation of file for stubbing
  1. Select the WSDL file from the temporary directory, for example: c:\wsdl\Quotation1.wsdl

Figure 32. Selection of the wsdl file for stubbing
Selection of the wsdl file for stubbing
  1. Click OK.

Figure 33. Click on Next button
Click on Next button
  1. Then click Next.

Figure 34. Finalization of stub creation
Finalization of stub creation
  1. Click Finish.
  2. Now, we will specify the behaviour of the stub: Specify the default stub response of quote to -1.0

Figure 35. Default stub answer setting
Default stub answer setting
  1. Define a new stub Equals Case:
    • Right-click DefaultCase and select Insert > Stub Equals Case.

Figure 36. Insertion of Stub Equals Case
Insertion of Stub Equals Case

In the Body of the request set the following values by selecting stub case name=Equals case:

market_place = New York
metal_name = gold


Figure 37. Set input parameters of the stub
set input parameters of the stub

In the response, select the ProvideQuotation1 parameter of the equal case and set it to 100.0


Figure 38. Set output parameters of the stub
set output parameters of the stub
  1. Create another equal case with the following values:
    market_place=Paris
    metal_name=gold

    For this input, set the response to 105.0
    You should have the stub behaviour set as follows:

Figure 39. Other Equals case setting
Other Equals case setting
  1. Save the stub.

Starting the local stub server

  1. Click on Deploy button in the stub editor.

Figure 40. Deployment of the stub
Deployment of the stub
  1. This creates a stub server on the local machine. Start the stub on the local machine by clicking the green arrow button

Figure 41. Run button of Stub Monitor view
Run button of Stub Monitor view
  1. In the stub monitor view, copy the URL of the WSDL of the Quotation1_Stub1 Web Service. You can import this WSDL into the Generic Service Client to test the stub.

Figure 42. Get WSDL URL published for the stub
get WSDL URL published for the stub

Testing the locally deployed stub with the Generic Service Client

  1. Click the Generic Service Client (GSC) icon

Figure 43. Generic Service Client icon
Generic Service Client icon
  1. Click on Add WSDL file
    Select Import from URL.

Figure 44. Importation of WSDL with stub URL
Importation of WSDL with stub URL
  1. Paste the URL of the WSDL file copied from the stub monitor view.

Figure 45. Paste publication URL of the stub
Paste publication URL of the stub
  1. Click OK.
  2. Test the default case

    Keep the default value for market_place and metal_name and click the Invoke button.

Figure 46. Invocation on the stub
invocation on the stub
  1. Check that the response is –1.0

Figure 47. Check quote response
Check quote response
  1. Test the values New York gold
    Click the Edit Data button
    Set market_place to New York
    Set metal_name to gold
    Click Invoke
    Check that the response is 100.0
  2. Test the values: Paris, gold
    Click the Edit Data button
    Set market_place to Paris
    Set metal_name to gold
    Click Invoke
    Check that the response is 105.0

Get the deployed QuotationInvoker Web Service WSDL file from the WebSphere Application Server 7.0 server

Before testing the Web Service invoker deployed on the WebSphere Application Server, you must get the associated/published QuotationInvokerWebServiceEAR WSDL file.

  1. Open the administrative console of the WebSphere server: Start > All Programs > IBM WebSphere > Application Server 7.0 > Profiles > AppServ01 > Administrative console
    Extend Applications and Application Types nodes
    Select WebSphere enterprise applications
    Click on QuotationInvokerWebServiceEAR

Figure 48. Selection of published application QuotationInvoker
Selection of published application QuotationInvoker
  1. Publish the WSDL file and copy it into the temporary folder, for example: c:\wsdl

Figure 49. Publish the WSDL file
Publish the WSDL file

Testing the QuotationInvoker Web Service with Rational Service Tester or Rational Performance Tester SOA Extension

Test recording

  1. In Rational Service Tester or Rational Performance Tester, click the New test from recording button.

Figure 50. Creation of a new recording
Creation of a new recording
  1. Select the Web Service recording using Generic Service Client.

Figure 51. Selection of recording using GSC
Selection of recording using GSC
  1. Click Next.
  2. Select TestQuotation and keep the default test file name.

Figure 52. Project Selection
Project Selection
  1. Click Next.
  2. Select Accept and click Finish.

Figure 53. Accept privacy warning
Accept privacy warning
  1. In the Generic Service Client, click the Add WSDL button.
  2. Select Import from file and select the WSDL file that you exported from WebSphere: c:\wsdl\QuotationInvoker.wsdl

Figure 54. Selection of WSDL QuotationInvoker
Selection of WSDL QuotationInvoker
  1. Click OK.
  2. Specify the end point of the deployed stub. Copy it from the stub monitor view.

Figure 55. Copy publication URL of the stub
Copy publication URL of the stub
  1. Paste into the endPparameter in the Generic Service Client.

Figure 56. endP setting with stub URL
endP setting with stub URL
  1. Click Invoke.
  2. You receive the response with the best quotation.

Figure 57. Response from QuotationInvoker
Response from QuotationInvoker

Paris has the best quotation value.

  1. You can change the behaviour of the stub by updating the value return for Paris from 105.0 to 95.0
    To do this, open the stub behaviour and simply change the return value for Paris to 95.0 and save the stub. The stub is automatically redeployed with new behaviour.

    In the Generic Service Client click Invoke again.
    Now, the best quotation is for the New York market place.

Figure 58. New Response from QuotationInvoker
New Response from QuotationInvoker
  1. Now, in the Call History list, delete the first call corresponding to the Paris best quotation response.

Figure 59. Delete first call
Delete first call
  1. Click the Stop recording button

Figure 60. Stop test suite recording
Stop test suite recording
  1. Answer Yes to open the generated test suite
  2. Select the response for GetBestQuotation and add an equal verification point.

Figure 61. Add verification point in test suite
Add verification point in test suite

Executing the generated test suite

  1. Click the Run button of the test suite or right click on the test suite and request a run. The test is executed

Figure 62. Execution of the test suite
Execution of the test suite

Generating a functional test report

  1. You can request the generation of a functional test report of the previous execution. Right click the result and select Generate Functional Report.

Figure 63. Requesting functional report generation
Requesting functional report generation

Figure 64. Selection of location for generation
Selection of location for generation
  1. Click Next.
  2. Select, for example, Service Test – Full (XSL)

Figure 65. Selection of report design
Selection of report design
  1. Click Finish.

The functional report is generated:


Figure 66. Result of functional report execution
Result of functional report execution

This report also includes test log data:


Figure 67. Test Log data in functional report
Test Log data in functional report

Resources

Learn

Get products and technologies

Discuss

About the author

Luc Auvray is an IBM software quality engineer and team lead in the Rational Toulouse development lab, in France. He currently works on IBM Rational Test RealTime, IBM Rational Service Tester for SOA and Performance Tester in the System Verification Team.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=SOA and web services, Rational, WebSphere
ArticleID=489434
ArticleTitle=Creation of web services with WebSphere Application Server V7 and testing with Rational Service Tester or Rational Performance Tester
publish-date=05252010
author1-email=luc.auvray@fr.ibm.com
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers