Client Code

Listing 3. The JAX-RPC client creates the service implementation, asks it for the required Web service port, and calls the appropriate method.

public class Client
{
  public static void main(String[] args)
  {
    AmazonSearchService_Impl impl = 
      new AmazonSearchService_Impl();

    AmazonSearchPort port = 
      impl.getAmazonSearchPort();

    AuthorRequest authorRequest = new AuthorRequest();
    authorRequest.setAuthor("Kevin Jones");
    authorRequest.setDevtag("[developer token here]");
    authorRequest.setMode("books");
    authorRequest.setKeywords("Web");
    authorRequest.setType("lite");
    try
    {
      ProductInfo productInfo = 
        port.authorSearchRequest(authorRequest);

      Details[] details = productInfo.getDetails();
      for (int ndx = 0; ndx < details.length; ndx++)
      {
        Details detail = details[ndx];
        System.out.println(detail.getProductName());
      }
    }
    catch (RemoteException e)
    {
      e.printStackTrace();
    }
  }
}