butek       02/04/24 08:47:38

  Modified:    java/samples/addr Main.java
  Log:
  Wrap the main code of the AddressBook sample within a try/catch block
  like other samples do (ie., GetQuote).  Error 404 is more obvious this way.
  Suggested by Jeff Barrett ([EMAIL PROTECTED]).
  
  Revision  Changes    Path
  1.19      +43 -31    xml-axis/java/samples/addr/Main.java
  
  Index: Main.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/samples/addr/Main.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Main.java 19 Apr 2002 18:12:22 -0000      1.18
  +++ Main.java 24 Apr 2002 15:47:38 -0000      1.19
  @@ -57,6 +57,8 @@
   
   package samples.addr;
   
  +import org.apache.axis.AxisFault;
  +
   import org.apache.axis.utils.Options;
   
   import java.net.URL;
  @@ -123,39 +125,49 @@
       }
       
       public static void main (String[] args) throws Exception {
  -        Options opts = new Options(args);
  -        
  -        System.err.println ("Using proxy without session maintenance.");
  -        System.err.println ("(queries without session should say:  \"ADDRESS NOT 
FOUND!\")");
  +        try {
  +            Options opts = new Options(args);
   
  -        AddressBookService abs = new AddressBookServiceLocator();
  -        opts.setDefaultURL( abs.getAddressBookAddress() );
  -        URL serviceURL = new URL(opts.getURL());
  -
  -        AddressBook ab1 = null;
  -        if (serviceURL == null) {
  -            ab1 = abs.getAddressBook();
  -        }
  -        else {
  -            ab1 = abs.getAddressBook(serviceURL);
  -        }
  -        Object ret = doit (ab1);
  -        if (ret != null) {
  -            throw new Exception("non-session test expected null response, got 
"+ret);
  -        }
  +            System.err.println ("Using proxy without session maintenance.");
  +            System.err.println ("(queries without session should say:  \"ADDRESS 
NOT FOUND!\")");
   
  -        System.err.println ("\n\nUsing proxy with session maintenance.");
  -        AddressBook ab2 = null;
  -        if (serviceURL == null) {
  -            ab2 = abs.getAddressBook();
  -        }
  -        else {
  -            ab2 = abs.getAddressBook(serviceURL);
  -        }
  -        ((AddressBookSOAPBindingStub) ab2).setMaintainSession (true);
  -        ret = doit (ab2);
  -        if (ret == null) {
  -            throw new Exception("session test expected non-null response, got 
"+ret);
  +            AddressBookService abs = new AddressBookServiceLocator();
  +            opts.setDefaultURL( abs.getAddressBookAddress() );
  +            URL serviceURL = new URL(opts.getURL());
  +
  +            AddressBook ab1 = null;
  +            if (serviceURL == null) {
  +                ab1 = abs.getAddressBook();
  +            }
  +            else {
  +                ab1 = abs.getAddressBook(serviceURL);
  +            }
  +            Object ret = doit (ab1);
  +            if (ret != null) {
  +                throw new Exception("non-session test expected null response, got 
"+ret);
  +            }
  +
  +            System.err.println ("\n\nUsing proxy with session maintenance.");
  +            AddressBook ab2 = null;
  +            if (serviceURL == null) {
  +                ab2 = abs.getAddressBook();
  +            }
  +            else {
  +                ab2 = abs.getAddressBook(serviceURL);
  +            }
  +            ((AddressBookSOAPBindingStub) ab2).setMaintainSession (true);
  +            ret = doit (ab2);
  +            if (ret == null) {
  +                throw new Exception("session test expected non-null response, got 
"+ret);
  +            }
  +        }
  +        catch (Exception e) {
  +            if (e instanceof AxisFault) {
  +                System.err.println(((AxisFault) e).dumpToString());
  +            }
  +            else {
  +                e.printStackTrace();
  +            }
           }
       }
   }
  
  
  


Reply via email to