1 package com.soapuser.soap.client.addressbook;
    2 
    3 // soapuser helper class
    4 import com.soapuser.soap.client.helper.*;
    5 
    6 // need impl classes
    7 import samples.addressbook.Address;
    8 import samples.addressbook.AddressBook;
    9 
   10 // need service intf
   11 import samples.addressbook.AddressBookInterface;
   12 
   13 import java.lang.reflect.UndeclaredThrowableException;
   14 
   15 public class AddressFetcher {
   16 
   17   public static void main(String[] args) {
   18 
   19     try {
   20       // init the helper
this is the main part
   21       SoapClientHelper.initService(
this is the Service Interface class
   22         AddressBookInterface.class,        // service interface
this is the path name of th DD to parse
   23         "file:C:/soap/soap-2_2/samples/addressbook/DeploymentDescriptor.xml",  // Service DD
this is the SOAP service URL
   24         "http://localhost:8080/soap/servlet/rpcrouter"); // URL for the calls
   25 
   26       // create the proxy object
this will create an instance of a proxy to the service
   27       AddressBookInterface addressBook = (AddressBookInterface)
   28         SoapClientHelper.makeServiceInstance( AddressBookInterface.class );
   29 
   30       // invoke
   31       String name = "John B. Good";
the call to the service is a straight java method!
   32       Address address = addressBook.getAddressFromName( name );
   33 
   34       // proof
   35       System.out.println( address.toString() );
   36     }
   37     catch ( UndeclaredThrowableException e ) {
   38       Throwable realException = e.getUndeclaredThrowable();
   39       System.out.println(realException.getMessage());
   40     }
   41     catch ( Exception e ) {
   42       System.out.println(e.getMessage());
   43       e.printStackTrace();
   44     }
   45   }
   46 }
HTML generated by Java2Html, © 2000 Think Tank Ltd, Douglas, Isle Of Man. All rights reserved