Novell is now a part of Micro Focus

Building and Running a Web Service Client that Consumes Amazon Web Services using the exteNd Workbench

Articles and Tips: article

01 Jan 2003


Here is a brief description of the few easy steps required to build and run a Web Service client that consumes Amazon Web Service using the eXtend Workbench. All you need to do is download and install the Workbench, run its Web Service wizard, modify the generated test class and run it. Estimated time after the software is installed is 5 minutes.

Background Information

Workbench overview can be found at the following URL:http://www.silverstream.com/workbench

The Workbench Web Services tutorial can be found at: http://devcenter2.silverstream.com/help/workbench40/docs/help/framesets/tutwbsPreface.fs.html

The Workbench Web Services Wizard Help can be found at: http://devcenter2.silverstream.com/help/workbench40/docs/help/framesets/toolsWebServiceWizard.fs.html

Software Requirements

Download the eXtend Workbench 4.0 software from: http://www.silverstream.com/workbenchdownload

Integrate to a Web Service Using an Existing WSDL

To integrate to a web service using an existing WSDL, perform the following steps:

  1. From the workbench menu select File->New Project

  2. Select JAR (Java Archive)

  3. Enter project name: AmazonWebService and select a location for the project by either entering the full pathname or by using the browse button to select a location.

  4. Click Next->Finish

  5. From the workbench main menu select File->New

  6. Click WebServices tab. Select Existing Web Service

  7. Enter package name, for example: com.sample.test

  8. Click Next

  9. Enter location of wsdl file (an URL that points to the wsdl): http://xml.amazon.com/schemas/AmazonWebServices.wsdl

  10. Click Next

  11. Click Finish

The eXtendWorkbench tool will now generate java code stubs that are required when interfacing to the existing web service. When the code generation is completed, click on the dialog box's OK button.

Modifying the Generated Client

The following client class will be generated: AmazonSearchPortClient.java. Modify the process() method of that class as follows:

public void process(String[] args) throws Exception
{
			AmazonSearchPort remote = getRemote(args);
// System.out.println("Test Result = " +
			// remote.artistSearchRequest(com.sample.test.ArtistRequest));
			//
			// Sample using artist search request API
			// Dump details of product returned from Amazons web service.
			ProductInfo productInfo = null;
			final String devTag = "DIBLHQV6QXF19";  // your dev tag
			productInfo = remote.artistSearchRequest(new ArtistRequest("Madonna", "1",
					"music", "webservices-20", "lite", devTag, "1.0") );
			//
			// Dump some data from Amazons database
			for(int index = 0; index < productInfo.getDetails().length; index++)
			{
					System.out.println("URL : " + productInfo.getDetails()[index].getUrl() +
					"\nAsin : " + productInfo.getDetails()[index].getAsin() +
					"\nProduct name : " + productInfo.getDetails()[index].getProductName() +
					"\nCatalog : " + productInfo.getDetails()[index].getCatalog() +
					"\nKey Phrases : " + productInfo.getDetails()[index].getKeyPhrases() +
					"\nRelease Date : " + productInfo.getDetails()[index].getReleaseDate() +
					"\nManufacturer : " + productInfo.getDetails()[index].getManufacturer() +
					"\nDistributor : " + productInfo.getDetails()[index].getDistributor() +
					"\nList Price : " + productInfo.getDetails()[index].getListPrice() +
					"\nOur Price : " + productInfo.getDetails()[index].getOurPrice() +
					"\nUsed Price : " + productInfo.getDetails()[index].getUsedPrice() +
					"\nRefurbushed Price : " + productInfo.getDetails()
							[index].getRefurbishedPrice()+ "\n");
			}
}

Compiling the Generated Code and Modified Client

Now that we have made the necessary modifications to the AmazonSearchPortClient.java class, now you need to compile the generated code with the modified client. To do this, perform the following steps:

  1. From the eXtendWorkbench main menu, select Project->Project Settings

  2. Select Classpath/Dependencies tab

  3. Click Add Entry

  4. Click Browse and navigate to the eXtendWorkbench/compilelib directory. Select all of the following files (%SILVERSTREAM_XWB_HOME% is your Workbench install directory):

    "%SILVERSTREAM_XWB_HOME%\compilelib\jaxm-api.jar" "%SILVERSTREAM_XWB_HOME%\compilelib\jaxp-api.jar" "%SILVERSTREAM_XWB_HOME%\compilelib\jaxrpc-api.jar" "%SILVERSTREAM_XWB_HOME%\compilelib\jbroker-web.jar" "%SILVERSTREAM_XWB_HOME%\compilelib\saaj-api.jar" "%SILVERSTREAM_XWB_HOME%\compilelib\saaj-ri.jar" "%SILVERSTREAM_XWB_HOME%\compilelib\xerces.jar"

  5. Click OK

  6. Click OK at the Project Setting dialog

  7. From the main toolbar, click the Build project and create archive icon.

  8. In the lower pane of the main eXtendWorkbench window, all files should be compiled and you should see a BUILD SUCCESSFUL message generated.

Running the Test Client

At this point, you are ready to run the test client. To do this, perform the following steps:

  1. From the main eXtendWorkbench menu, select Project->Run Web Service Client Class

  2. Click Run on the Web Service Client Runner dialog. You should see output similar to the following:


URL : http://www.amazon.com/exec/obidos/redirect?tag=webservices-20%26
creative=DIBLHQV6QXF19%26camp=2025%26link_code=sp1%26path=ASIN/B000002LND
Asin : B000002LND
Product name : The Immaculate Collection
Catalog : Music
Key Phrases : null
Release Date : 08 December, 1990
Manufacturer : Warner Brothers
Distributor : null
List Price : $18.98
Our Price : $13.49
Used Price : null
Refurbushed Price : null

* Originally published in Novell AppNotes


Disclaimer

The origin of this information may be internal or external to Novell. While Novell makes all reasonable efforts to verify this information, Novell does not make explicit or implied claims to its validity.

© Copyright Micro Focus or one of its affiliates