Walkthrough: AWS: Java Code Sample: Step 5

Step: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | N

5) Run client.axis.sh to generate client stubs 

In the previous step, you saw that the WSDL file describes the Amazon web service. The WSDL describes every single type of query you can make against the Amazon web service. These queries include a book search (AsinSearch), a WishList search, a Keyword search, and many others. The WSDL also describes all the search parameters and all the fields that are present in its response.

The key to writing a Java Amazon web service client is to produce Java code to set the parameters, initiate the search, and then read the fields in the response. Axis provides a way to generate all of this "boilerplate" code for all of Amazon's search query types directly from the WSDL file.

Open the client.axis.sh or client.axis.bat file. This file contains this one important line:

java org.apache.axis.wsdl.WSDL2Java -v -p com.amazon.soap.axis AmazonWebServices.wsdl

In either DOS or Cygwin, you can type in the above line and Axis' WSDL2Java program will generate all the "boilerplate" code. This is what will happen when you type in this line:

% java org.apache.axis.wsdl.WSDL2Java -v 
	-p com.amazon.soap.axis AmazonWebServices.wsdl
Parsing XML file:  AmazonWebServices.wsdl
Generating com\amazon\soap\axis\ExchangeRequest.java
Generating com\amazon\soap\axis\AsinRequest.java
Generating com\amazon\soap\axis\OrderItem.java

... lots of output omitted ...

Generating com\amazon\soap\axis\AmazonSearchServiceLocator.java
Generating com\amazon\soap\axis\AmazonSearchPort.java
Generating com\amazon\soap\axis\AmazonSearchBindingStub.java

The key thing to realize is that the WSDL2Java from Axis will generate files in the directory tree com/amazon/soap/axis:

% ls -R com
com:
amazon/

com/amazon:
soap/

com/amazon/soap:
axis/

com/amazon/soap/axis:
ActorRequest.java                   MarketplaceRequest.java
AddItem.java                        MarketplaceSearch.java
AddShoppingCartItemsRequest.java    MarketplaceSearchDetails.java
AmazonSearchBindingStub.java        ModifyShoppingCartItemsRequest.java
AmazonSearchPort.java               OrderItem.java
AmazonSearchService.java            PowerRequest.java
AmazonSearchServiceLocator.java     Price.java
ArtistRequest.java                  ProductInfo.java
AsinRequest.java                    ProductLine.java
AuthorRequest.java                  RemoveShoppingCartItemsRequest.java
BlendedRequest.java                 Reviews.java
BrowseNode.java                     SellerFeedback.java
BrowseNodeRequest.java              SellerProfile.java
ClearShoppingCartRequest.java       SellerProfileDetails.java
CustomerReview.java                 SellerProfileRequest.java
Details.java                        SellerRequest.java
DirectorRequest.java                SellerSearch.java
ExchangeRequest.java                SellerSearchDetails.java
FeaturedProduct.java                ShoppingCart.java
Feedback.java                       ShortSummary.java
GetShoppingCartRequest.java         SimilarityRequest.java
GetTransactionDetailsRequest.java   SkuRequest.java
GetTransactionDetailsResponse.java  TextStreamRequest.java
Item.java                           ThirdPartyProductDetails.java
ItemQuantity.java                   ThirdPartyProductInfo.java
KeyPhrase.java                      Track.java
KeywordRequest.java                 UpcRequest.java
ListManiaRequest.java               Variation.java
ListingProductDetails.java          WishlistRequest.java
ListingProductInfo.java             _package.java
ManufacturerRequest.java

These files will be used by the code in the JavaSampleCode directory.

Next
Step: 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | N


Rick (rgu@TheWorld.com) Umali
Last Update: 2/24/2004