antelder    2002/12/12 12:19:13

  Modified:    java/samples/complexsoap/client/stub Run.java
               java/samples/localjava/client/stub Run.java
               java/samples/complexsoap/client/dynamic Run.java
               java/samples/simplesoap/client/stub Run.java
               java/samples/localjava/client/dynamic Run.java
  Log:
  Format the samples code
  
  Revision  Changes    Path
  1.3       +63 -36    xml-axis-wsif/java/samples/complexsoap/client/stub/Run.java
  
  Index: Run.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/complexsoap/client/stub/Run.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Run.java  10 Dec 2002 15:31:20 -0000      1.2
  +++ Run.java  12 Dec 2002 20:19:12 -0000      1.3
  @@ -17,41 +17,68 @@
    */
   
   public class Run {
  -    public static void main(String [] args) {
  -     try {
  -         if (args.length!=2) {
  -             System.out.println("Usage: java samples.complexsoap.client.stub.Run 
<wsdl location> <zip code>");
  -             System.exit(1);
  -         }
  -         // create a service factory
  -         WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  -         // parse WSDL
  -         WSIFService service = factory.getService(args[0], null,
  -                                                  null, "http://ws.cdyne.com";, 
  -                                                  "Zip2GeoSoap"); 
  -         // map types
  -         service.mapType(new QName("http://ws.cdyne.com","LatLongReturn";),
  -                         
Class.forName("complexsoap.client.stub.com.cdyne.ws.LatLongReturn"));
  -         Zip2GeoSoap stub = null;
  -         // create the stub
  -         stub = (Zip2GeoSoap) service.getStub(Zip2GeoSoap.class);
  -         // do the invocation
  -         // args[1] is the zip code
  -         LatLongReturn zipInfo = stub.GetLatLong(args[1],"");
  -         System.out.println("This zip code is in 
"+zipInfo.getCity()+","+zipInfo.getStateAbbrev()+
  -                            " in "+zipInfo.getCounty()+" county\n"+
  -                            "It extends from longitude 
"+zipInfo.getFromLongitude()+" to longitude "+
  -                            zipInfo.getToLongitude()+"\n and from latitude 
"+zipInfo.getFromLatitude()+
  -                            " to latitude "+zipInfo.getToLatitude());
  -     } catch (WSIFException we) {
  -         System.out.println("Error while executing sample, received an exception 
from WSIF; details:");
  -         we.printStackTrace();
  -     } catch (RemoteException re) {
  -         System.out.println("Error while executing sample, received an exception 
due to remote invocation; details:");
  -         re.printStackTrace();
  -     } catch (ClassNotFoundException ce) {
  -         System.out.println("Error while executing sample, could not find required 
class complexsoap.client.stub.com.cdyne.ws.LatLongReturn; please add it to your 
classpath; details:");
  -         ce.printStackTrace();
  -     }
  +    public static void main(String[] args) {
  +        try {
  +            if (args.length != 2) {
  +                System.out.println(
  +                    "Usage: java samples.complexsoap.client.stub.Run <wsdl 
location> <zip code>");
  +                System.exit(1);
  +            }
  +
  +            // create a service factory
  +            WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  +
  +            // parse WSDL
  +            WSIFService service =
  +                factory.getService(
  +                    args[0],
  +                    null,
  +                    null,
  +                    "http://ws.cdyne.com";,
  +                    "Zip2GeoSoap");
  +
  +            // map types
  +            service.mapType(
  +                new QName("http://ws.cdyne.com";, "LatLongReturn"),
  +                Class.forName(
  +                    "complexsoap.client.stub.com.cdyne.ws.LatLongReturn"));
  +
  +            // create the stub
  +            Zip2GeoSoap stub = (Zip2GeoSoap) service.getStub(Zip2GeoSoap.class);
  +
  +            // do the invocation
  +            // args[1] is the zip code
  +            LatLongReturn zipInfo = stub.GetLatLong(args[1], "");
  +
  +            System.out.println(
  +                "This zip code is in "
  +                    + zipInfo.getCity()
  +                    + ","
  +                    + zipInfo.getStateAbbrev()
  +                    + " in "
  +                    + zipInfo.getCounty()
  +                    + " county\n"
  +                    + "It extends from longitude "
  +                    + zipInfo.getFromLongitude()
  +                    + " to longitude "
  +                    + zipInfo.getToLongitude()
  +                    + "\n and from latitude "
  +                    + zipInfo.getFromLatitude()
  +                    + " to latitude "
  +                    + zipInfo.getToLatitude());
  +
  +        } catch (WSIFException we) {
  +            System.out.println(
  +                "Error while executing sample, received an exception from WSIF; 
details:");
  +            we.printStackTrace();
  +        } catch (RemoteException re) {
  +            System.out.println(
  +                "Error while executing sample, received an exception due to remote 
invocation; details:");
  +            re.printStackTrace();
  +        } catch (ClassNotFoundException ce) {
  +            System.out.println(
  +                "Error while executing sample, could not find required class 
complexsoap.client.stub.com.cdyne.ws.LatLongReturn; please add it to your classpath; 
details:");
  +            ce.printStackTrace();
  +        }
       }
   }
  
  
  
  1.2       +145 -102  xml-axis-wsif/java/samples/localjava/client/stub/Run.java
  
  Index: Run.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/localjava/client/stub/Run.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Run.java  11 Dec 2002 20:38:40 -0000      1.1
  +++ Run.java  12 Dec 2002 20:19:12 -0000      1.2
  @@ -1,12 +1,14 @@
   package localjava.client.stub;
   
  +import java.rmi.RemoteException;
  +
  +import localjava.client.stub.addressbook.wsifservice.AddressBook;
  +import localjava.client.stub.addressbook.wsiftypes.Address;
  +import localjava.client.stub.addressbook.wsiftypes.Phone;
  +
  +import org.apache.wsif.WSIFException;
   import org.apache.wsif.WSIFService;
   import org.apache.wsif.WSIFServiceFactory;
  -import org.apache.wsif.WSIFException;
  -import java.rmi.RemoteException;
  -import addressbook.wsiftypes.Address;
  -import addressbook.wsiftypes.Phone;
  -import addressbook.wsifservice.AddressBook;
   
   /**
    * Class that runs the localjava sample using a pregenerated stub interface
  @@ -19,109 +21,150 @@
   
   public class Run {
       private static void addFirstAddress(AddressBook addressBook) {
  -     try {
  -         // create an address object to populate the input
  -         Address address = new Address();
  -         address.setStreetNum(25);
  -         address.setStreetName("Willow Road");
  -         address.setCity("MyTown");
  -         address.setState("PA");
  -         address.setZip(28382);
  -         Phone phone = new Phone();
  -         phone.setAreaCode(288);
  -         phone.setExchange("555");
  -         phone.setNumber("9891");
  -         address.setPhoneNumber(phone);
  -         // do the invocation
  -         System.out.println("Adding address for John Smith...");
  -         addressBook.addEntry("John Smith",address);
  -     } catch (WSIFException we) {
  -         System.out.println("Got exception from WSIF, details:");
  -         we.printStackTrace();
  -     } catch (RemoteException re) {
  -         System.out.println("Got exception while invoking stub, details:");
  -         re.printStackTrace();
  -     }
  +        try {
  +             
  +            // create an address object to populate the input
  +            Address address = new Address();
  +            address.setStreetNum(25);
  +            address.setStreetName("Willow Road");
  +            address.setCity("MyTown");
  +            address.setState("PA");
  +            address.setZip(28382);
  +            Phone phone = new Phone();
  +            phone.setAreaCode(288);
  +            phone.setExchange("555");
  +            phone.setNumber("9891");
  +            address.setPhoneNumber(phone);
  +
  +            // do the invocation
  +            System.out.println("Adding address for John Smith...");
  +            addressBook.addEntry("John Smith", address);
  +
  +        } catch (WSIFException we) {
  +            System.out.println("Got exception from WSIF, details:");
  +            we.printStackTrace();
  +        } catch (RemoteException re) {
  +            System.out.println("Got exception while invoking stub, details:");
  +            re.printStackTrace();
  +        }
       }
  -     
  +
       private static void addSecondAddress(AddressBook addressBook) {
  -     try {
  -         // create an address object to populate the input
  -         Address address = new Address();
  -         address.setStreetNum(20);
  -         address.setStreetName("Peachtree Avenue");
  -         address.setCity("Atlanta");
  -         address.setState("GA");
  -         address.setZip(39892);
  -         Phone phone = new Phone();
  -         phone.setAreaCode(701);
  -         phone.setExchange("555");
  -         phone.setNumber("8721");
  -         address.setPhoneNumber(phone);
  -         // do the invocation
  -         System.out.println("Adding address for Jane White...");
  -         addressBook.addEntry("Jane","White",address);
  -     } catch (WSIFException we) {
  -         System.out.println("Got exception from WSIF, details:");
  -         we.printStackTrace();
  -     } catch (RemoteException re) {
  -         System.out.println("Got exception while invoking stub, details:");
  -         re.printStackTrace();
  -     }
  +        try {
  +             
  +            // create an address object to populate the input
  +            Address address = new Address();
  +            address.setStreetNum(20);
  +            address.setStreetName("Peachtree Avenue");
  +            address.setCity("Atlanta");
  +            address.setState("GA");
  +            address.setZip(39892);
  +            Phone phone = new Phone();
  +            phone.setAreaCode(701);
  +            phone.setExchange("555");
  +            phone.setNumber("8721");
  +            address.setPhoneNumber(phone);
  +
  +            // do the invocation
  +            System.out.println("Adding address for Jane White...");
  +            addressBook.addEntry("Jane", "White", address);
  +
  +        } catch (WSIFException we) {
  +            System.out.println("Got exception from WSIF, details:");
  +            we.printStackTrace();
  +        } catch (RemoteException re) {
  +            System.out.println("Got exception while invoking stub, details:");
  +            re.printStackTrace();
  +        }
       }
   
       private static void queryAddresses(AddressBook addressBook) {
  -     try {
  -         // do the invocation
  -         System.out.println("Querying address for John Smith...");
  -         Address address = addressBook.getAddressFromName("John Smith");
  -         System.out.println("Service returned the following address:");
  -         System.out.println(address.getStreetNum()+" "+address.getStreetName()+
  -                            ", "+address.getCity()+" "+address.getState()+" "+
  -                            address.getZip()+"; Phone: ("+
  -                            address.getPhoneNumber().getAreaCode()+") "+
  -                            address.getPhoneNumber().getExchange()+"-"+
  -                            address.getPhoneNumber().getNumber());
  -         System.out.println("Querying address for Jane White...");
  -         address = addressBook.getAddressFromName("Jane White");
  -         System.out.println("Service returned the following address:");
  -         System.out.println(address.getStreetNum()+" "+address.getStreetName()+
  -                            ", "+address.getCity()+" "+address.getState()+" "+
  -                            address.getZip()+"; Phone: ("+
  -                            address.getPhoneNumber().getAreaCode()+") "+
  -                            address.getPhoneNumber().getExchange()+"-"+
  -                            address.getPhoneNumber().getNumber());
  -     } catch (WSIFException we) {
  -         System.out.println("Got exception from WSIF, details:");
  -         we.printStackTrace();
  -     } catch (RemoteException re) {
  -         System.out.println("Got exception while invoking stub, details:");
  -         re.printStackTrace();
  -     }
  +        try {
  +
  +            // do the invocation
  +            System.out.println("Querying address for John Smith...");
  +            Address address = addressBook.getAddressFromName("John Smith");
  +
  +            System.out.println("Service returned the following address:");
  +            System.out.println(
  +                address.getStreetNum()
  +                    + " "
  +                    + address.getStreetName()
  +                    + ", "
  +                    + address.getCity()
  +                    + " "
  +                    + address.getState()
  +                    + " "
  +                    + address.getZip()
  +                    + "; Phone: ("
  +                    + address.getPhoneNumber().getAreaCode()
  +                    + ") "
  +                    + address.getPhoneNumber().getExchange()
  +                    + "-"
  +                    + address.getPhoneNumber().getNumber());
  +
  +            System.out.println("Querying address for Jane White...");
  +            address = addressBook.getAddressFromName("Jane White");
  +
  +            System.out.println("Service returned the following address:");
  +            System.out.println(
  +                address.getStreetNum()
  +                    + " "
  +                    + address.getStreetName()
  +                    + ", "
  +                    + address.getCity()
  +                    + " "
  +                    + address.getState()
  +                    + " "
  +                    + address.getZip()
  +                    + "; Phone: ("
  +                    + address.getPhoneNumber().getAreaCode()
  +                    + ") "
  +                    + address.getPhoneNumber().getExchange()
  +                    + "-"
  +                    + address.getPhoneNumber().getNumber());
  +
  +        } catch (WSIFException we) {
  +            System.out.println("Got exception from WSIF, details:");
  +            we.printStackTrace();
  +        } catch (RemoteException re) {
  +            System.out.println("Got exception while invoking stub, details:");
  +            re.printStackTrace();
  +        }
       }
   
  -    public static void main(String [] args) {
  -     try {
  -         if (args.length!=1) {
  -             System.out.println("Usage: java samples.localjava.client.stub.Run 
<wsdl location>");
  -             System.exit(1);
  -         }
  -         // create a service factory
  -         WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  -         // parse WSDL
  -         WSIFService service = factory.getService(args[0], null,
  -                                                  null, 
"http://wsifservice.addressbook/";, 
  -                                                  "AddressBook"); 
  -         AddressBook stub = null;
  -         // create the stub
  -         stub = (AddressBook) service.getStub(AddressBook.class);
  -         // do the invocations
  -         addFirstAddress(stub);
  -         addSecondAddress(stub);
  -         queryAddresses(stub);
  -     } catch (WSIFException we) {
  -         System.out.println("Got exception from WSIF, details:");
  -         we.printStackTrace();
  -     }
  +    public static void main(String[] args) {
  +        try {
  +            if (args.length != 1) {
  +                System.out.println(
  +                    "Usage: java samples.localjava.client.stub.Run <wsdl 
location>");
  +                System.exit(1);
  +            }
  +
  +            // create a service factory
  +            WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  +
  +            // parse WSDL
  +            WSIFService service =
  +                factory.getService(
  +                    args[0],
  +                    null,
  +                    null,
  +                    "http://wsifservice.addressbook/";,
  +                    "AddressBook");
  +
  +            // create the stub
  +            AddressBook stub =
  +                (AddressBook) service.getStub(AddressBook.class);
  +
  +            // do the invocations
  +            addFirstAddress(stub);
  +            addSecondAddress(stub);
  +            queryAddresses(stub);
  +
  +        } catch (WSIFException we) {
  +            System.out.println("Got exception from WSIF, details:");
  +            we.printStackTrace();
  +        }
       }
   }
  
  
  
  1.3       +65 -42    xml-axis-wsif/java/samples/complexsoap/client/dynamic/Run.java
  
  Index: Run.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/complexsoap/client/dynamic/Run.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Run.java  10 Dec 2002 15:31:20 -0000      1.2
  +++ Run.java  12 Dec 2002 20:19:12 -0000      1.3
  @@ -10,49 +10,72 @@
   
   import complexsoap.client.stub.com.cdyne.ws.LatLongReturn;
   
  -
   public class Run {
  -    public static void main(String [] args) throws Exception {
  -     // args[0] is the zip code
  -     if(args.length!=2) {
  -         System.out.println("Usage: java samples.complexsoap.client.dynamic.Run 
<wsdl location> <zip code>");
  -         System.exit(1);
  -     }
  -     // create a service factory
  +    public static void main(String[] args) throws Exception {
  +     
  +        // args[0] is the zip code
  +        if (args.length != 2) {
  +            System.out.println(
  +                "Usage: java samples.complexsoap.client.dynamic.Run <wsdl location> 
<zip code>");
  +            System.exit(1);
  +        }
  +        
  +        // create a service factory
           WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  -     
  -     WSIFService service = factory.getService(args[0], null,
  -                                              null, "http://ws.cdyne.com";, 
  -                                              "Zip2GeoSoap"); 
  -     // map types
  -     service.mapType(new QName("http://ws.cdyne.com","LatLongReturn";),
  -                     
Class.forName("complexsoap.client.stub.com.cdyne.ws.LatLongReturn"));
  -
  -     // get the port
  -     WSIFPort port = service.getPort();
  -     // create the operation
  -     WSIFOperation operation = port.createOperation("GetLatLong");
  -     // create the input, output and fault messages associated with this operation
  -     WSIFMessage input = operation.createInputMessage();
  -     WSIFMessage output = operation.createOutputMessage();
  -     WSIFMessage fault = operation.createFaultMessage();
  -     // populate the input message
  -     input.setObjectPart("zipcode",args[1]);
  -     input.setObjectPart("LicenseKey","");
  -     // do the invocation
  -     if (operation.executeRequestResponseOperation(input, output, 
  -                                                   fault)) {
  -         // invocation succeeded, extract information from output 
  -         // message
  -         LatLongReturn zipInfo = (LatLongReturn) 
output.getObjectPart("GetLatLongResult");
  -         System.out.println("This zip code is in 
"+zipInfo.getCity()+","+zipInfo.getStateAbbrev()+
  -                            " in "+zipInfo.getCounty()+" county\n"+
  -                            "It extends from longitude 
"+zipInfo.getFromLongitude()+" to longitude "+
  -                            zipInfo.getToLongitude()+"\n and from latitude 
"+zipInfo.getFromLatitude()+
  -                            " to latitude "+zipInfo.getToLatitude());
  -     } else {
  -         System.out.println("Invocation failed");
  -         // extract fault message info
  -     }
  +        WSIFService service =
  +            factory.getService(
  +                args[0],
  +                null,
  +                null,
  +                "http://ws.cdyne.com";,
  +                "Zip2GeoSoap");
  +
  +        // map types
  +        service.mapType(
  +            new QName("http://ws.cdyne.com";, "LatLongReturn"),
  +            Class.forName(
  +                "complexsoap.client.stub.com.cdyne.ws.LatLongReturn"));
  +
  +        // get the port
  +        WSIFPort port = service.getPort();
  +
  +        // create the operation
  +        WSIFOperation operation = port.createOperation("GetLatLong");
  +
  +        // create the input, output and fault messages associated with this 
operation
  +        WSIFMessage input = operation.createInputMessage();
  +        WSIFMessage output = operation.createOutputMessage();
  +        WSIFMessage fault = operation.createFaultMessage();
  +
  +        // populate the input message
  +        input.setObjectPart("zipcode", args[1]);
  +        input.setObjectPart("LicenseKey", "");
  +
  +        // do the invocation
  +        if (operation.executeRequestResponseOperation(input, output, fault)) {
  +            // invocation succeeded, extract information from output 
  +            // message
  +            LatLongReturn zipInfo =
  +                (LatLongReturn) output.getObjectPart("GetLatLongResult");
  +            System.out.println(
  +                "This zip code is in "
  +                    + zipInfo.getCity()
  +                    + ","
  +                    + zipInfo.getStateAbbrev()
  +                    + " in "
  +                    + zipInfo.getCounty()
  +                    + " county\n"
  +                    + "It extends from longitude "
  +                    + zipInfo.getFromLongitude()
  +                    + " to longitude "
  +                    + zipInfo.getToLongitude()
  +                    + "\n and from latitude "
  +                    + zipInfo.getFromLatitude()
  +                    + " to latitude "
  +                    + zipInfo.getToLatitude());
  +        } else {
  +            System.out.println("Invocation failed");
  +            // extract fault message info
  +        }
       }
   }
  
  
  
  1.3       +40 -26    xml-axis-wsif/java/samples/simplesoap/client/stub/Run.java
  
  Index: Run.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/simplesoap/client/stub/Run.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Run.java  10 Dec 2002 15:31:20 -0000      1.2
  +++ Run.java  12 Dec 2002 20:19:13 -0000      1.3
  @@ -15,31 +15,45 @@
    */
   
   public class Run {
  -    public static void main(String [] args) {
  -     try {
  -         if (args.length!=2) {
  -             System.out.println("Usage: java samples.simplesoap.client.stub.Run 
<wsdl location> <company symbol>");
  -             System.exit(1);
  -         }
  -         // create a service factory
  -         WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  -         // parse WSDL
  -         WSIFService service = factory.getService(args[0], null,
  -                                                  null, 
"http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuote/";, 
  -                                                  
"net.xmethods.services.stockquote.StockQuotePortType"); 
  -         NetXmethodsServicesStockquoteStockQuotePortType stub = null;
  -         // create the stub
  -         stub = (NetXmethodsServicesStockquoteStockQuotePortType) 
service.getStub(NetXmethodsServicesStockquoteStockQuotePortType.class);
  -         // do the invocation
  -         // args[1] is the company symbol
  -         float quote = stub.getQuote(args[1]);
  -         System.out.println(quote);
  -     } catch (WSIFException we) {
  -         System.out.println("Error while executing sample, received an exception 
from WSIF; details:");
  -         we.printStackTrace();
  -     } catch (RemoteException re) {
  -         System.out.println("Error while executing sample, received an exception 
due to remote invocation; details:");
  -         re.printStackTrace();
  -     }
  +     
  +    public static void main(String[] args) {
  +        try {
  +
  +            if (args.length != 2) {
  +                System.out.println(
  +                    "Usage: java samples.simplesoap.client.stub.Run <wsdl location> 
<company symbol>");
  +                System.exit(1);
  +            }
  +
  +            // create a service factory
  +            WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  +
  +            // parse WSDL
  +            WSIFService service =
  +                factory.getService(
  +                    args[0],
  +                    null,
  +                    null,
  +                    
"http://www.themindelectric.com/wsdl/net.xmethods.services.stockquote.StockQuote/";,
  +                    "net.xmethods.services.stockquote.StockQuotePortType");
  +            // create the stub
  +            NetXmethodsServicesStockquoteStockQuotePortType stub = 
  +                    (NetXmethodsServicesStockquoteStockQuotePortType) 
service.getStub(
  +                        NetXmethodsServicesStockquoteStockQuotePortType.class);
  +
  +            // do the invocation
  +            // args[1] is the company symbol
  +            float quote = stub.getQuote(args[1]);
  +            System.out.println(quote);
  +
  +        } catch (WSIFException we) {
  +            System.out.println(
  +                "Error while executing sample, received an exception from WSIF; 
details:");
  +            we.printStackTrace();
  +        } catch (RemoteException re) {
  +            System.out.println(
  +                "Error while executing sample, received an exception due to remote 
invocation; details:");
  +            re.printStackTrace();
  +        }
       }
   }
  
  
  
  1.2       +199 -137  xml-axis-wsif/java/samples/localjava/client/dynamic/Run.java
  
  Index: Run.java
  ===================================================================
  RCS file: /home/cvs/xml-axis-wsif/java/samples/localjava/client/dynamic/Run.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Run.java  11 Dec 2002 20:38:40 -0000      1.1
  +++ Run.java  12 Dec 2002 20:19:13 -0000      1.2
  @@ -13,151 +13,213 @@
   import addressbook.wsiftypes.Phone;
   
   public class Run {
  +
       private static void addFirstAddress(WSIFPort port) {
  -     try {
  -         // create the operation
  -         // note that we have two operations with the same name, so we need to 
specify the
  -         // name of the input and output messages as well
  -         WSIFOperation operation = 
port.createOperation("addEntry","AddEntryWholeNameRequest",null);
  -         // create the input message associated with this operation
  -         WSIFMessage input = operation.createInputMessage();
  -         // populate the input message
  -         input.setObjectPart("name","John Smith");
  -         // create an address object to populate the input
  -         Address address = new Address();
  -         address.setStreetNum(25);
  -         address.setStreetName("Willow Road");
  -         address.setCity("MyTown");
  -         address.setState("PA");
  -         address.setZip(28382);
  -         Phone phone = new Phone();
  -         phone.setAreaCode(288);
  -         phone.setExchange("555");
  -         phone.setNumber("9891");
  -         address.setPhoneNumber(phone);
  -         input.setObjectPart("address",address);
  -         // do the invocation
  -         System.out.println("Adding address for John Smith...");
  -         operation.executeInputOnlyOperation(input);
  -     } catch (WSIFException we) {
  -         System.out.println("Got exception from WSIF, details:");
  -         we.printStackTrace();
  -     }
  +        try {
  +            // create the operation
  +            // note that we have two operations with the same name, 
  +            // so we need to specify the name of the input and output 
  +            // messages as well
  +            WSIFOperation operation =
  +                port.createOperation(
  +                    "addEntry",
  +                    "AddEntryWholeNameRequest",
  +                    null);
  +                    
  +            // create the input message associated with this operation
  +            WSIFMessage input = operation.createInputMessage();
  +
  +            // populate the input message
  +            input.setObjectPart("name", "John Smith");
  +
  +            // create an address object to populate the input
  +            Address address = new Address();
  +            address.setStreetNum(25);
  +            address.setStreetName("Willow Road");
  +            address.setCity("MyTown");
  +            address.setState("PA");
  +            address.setZip(28382);
  +            Phone phone = new Phone();
  +            phone.setAreaCode(288);
  +            phone.setExchange("555");
  +            phone.setNumber("9891");
  +            address.setPhoneNumber(phone);
  +
  +            input.setObjectPart("address", address);
  +
  +            // do the invocation
  +            System.out.println("Adding address for John Smith...");
  +            operation.executeInputOnlyOperation(input);
  +
  +        } catch (WSIFException we) {
  +            System.out.println("Got exception from WSIF, details:");
  +            we.printStackTrace();
  +        }
       }
  -     
  +
       private static void addSecondAddress(WSIFPort port) {
  -     try {
  -         // create the operation
  -         // note that we have two operations with the same name, so we need to 
specify the
  -         // name of the input and output messages as well
  -         WSIFOperation operation = 
port.createOperation("addEntry","AddEntryFirstAndLastNamesRequest",null);
  -         // create the input message associated with this operation
  -         WSIFMessage input = operation.createInputMessage();
  -         // populate the input message
  -         input.setObjectPart("firstName","Jane");
  -         input.setObjectPart("lastName","White");
  -         // create an address object to populate the input
  -         Address address = new Address();
  -         address.setStreetNum(20);
  -         address.setStreetName("Peachtree Avenue");
  -         address.setCity("Atlanta");
  -         address.setState("GA");
  -         address.setZip(39892);
  -         Phone phone = new Phone();
  -         phone.setAreaCode(701);
  -         phone.setExchange("555");
  -         phone.setNumber("8721");
  -         address.setPhoneNumber(phone);
  -         input.setObjectPart("address",address);
  -         // do the invocation
  -         System.out.println("Adding address for Jane White...");
  -         operation.executeInputOnlyOperation(input);
  -     } catch (WSIFException we) {
  -         System.out.println("Got exception from WSIF, details:");
  -         we.printStackTrace();
  -     }
  +        try {
  +
  +            // create the operation
  +            // note that we have two operations with the same name, so we need to 
specify the
  +            // name of the input and output messages as well
  +            WSIFOperation operation =
  +                port.createOperation(
  +                    "addEntry",
  +                    "AddEntryFirstAndLastNamesRequest",
  +                    null);
  +
  +            // create the input message associated with this operation
  +            WSIFMessage input = operation.createInputMessage();
  +
  +            // populate the input message
  +            input.setObjectPart("firstName", "Jane");
  +            input.setObjectPart("lastName", "White");
  +
  +            // create an address object to populate the input
  +            Address address = new Address();
  +            address.setStreetNum(20);
  +            address.setStreetName("Peachtree Avenue");
  +            address.setCity("Atlanta");
  +            address.setState("GA");
  +            address.setZip(39892);
  +            Phone phone = new Phone();
  +            phone.setAreaCode(701);
  +            phone.setExchange("555");
  +            phone.setNumber("8721");
  +            address.setPhoneNumber(phone);
  +
  +            input.setObjectPart("address", address);
  +
  +            // do the invocation
  +            System.out.println("Adding address for Jane White...");
  +            operation.executeInputOnlyOperation(input);
  +
  +        } catch (WSIFException we) {
  +            System.out.println("Got exception from WSIF, details:");
  +            we.printStackTrace();
  +        }
       }
   
       private static void queryAddresses(WSIFPort port) {
  -     try {
  -         // create the operation
  -         WSIFOperation operation = port.createOperation("getAddressFromName");
  -         // create the input message associated with this operation
  -         WSIFMessage input = operation.createInputMessage();
  -         WSIFMessage output = operation.createOutputMessage();
  -         WSIFMessage fault = operation.createFaultMessage();
  -         // populate the input message
  -         input.setObjectPart("name","John Smith");
  -         // do the invocation
  -         System.out.println("Querying address for John Smith...");
  -         if (operation.executeRequestResponseOperation(input,output,fault)) {
  -             // invocation succeeded
  -             // extract the address from the output message
  -             Address address = (Address) output.getObjectPart("address");
  -             System.out.println("Service returned the following address:");
  -             System.out.println(address.getStreetNum()+" "+address.getStreetName()+
  -                                ", "+address.getCity()+" "+address.getState()+" "+
  -                                address.getZip()+"; Phone: ("+
  -                                address.getPhoneNumber().getAreaCode()+") "+
  -                                address.getPhoneNumber().getExchange()+"-"+
  -                                address.getPhoneNumber().getNumber());
  -         } else {
  -             // invocation failed, check fault message
  -         }
  -         // create the operation
  -         operation = port.createOperation("getAddressFromName");
  -         // create the input message associated with this operation
  -         input = operation.createInputMessage();
  -         output = operation.createOutputMessage();
  -         fault = operation.createFaultMessage();
  -         // populate the input message
  -         input.setObjectPart("name","Jane White");
  -         // do the invocation
  -         System.out.println("Querying address for Jane White...");
  -         if (operation.executeRequestResponseOperation(input,output,fault)) {
  -             // invocation succeeded
  -             // extract the address from the output message
  -             Address address = (Address) output.getObjectPart("address");
  -             System.out.println("Service returned the following address:");
  -             System.out.println(address.getStreetNum()+" "+address.getStreetName()+
  -                                ", "+address.getCity()+" "+address.getState()+" "+
  -                                address.getZip()+"; Phone: ("+
  -                                address.getPhoneNumber().getAreaCode()+") "+
  -                                address.getPhoneNumber().getExchange()+"-"+
  -                                address.getPhoneNumber().getNumber());
  -         } else {
  -             // invocation failed, check fault message
  -         }
  -     } catch (WSIFException we) {
  -         System.out.println("Got exception from WSIF, details:");
  -         we.printStackTrace();
  -     }
  +        try {
  +            // create the operation
  +            WSIFOperation operation =
  +                port.createOperation("getAddressFromName");
  +
  +            // create the input message associated with this operation
  +            WSIFMessage input = operation.createInputMessage();
  +            WSIFMessage output = operation.createOutputMessage();
  +            WSIFMessage fault = operation.createFaultMessage();
  +
  +            // populate the input message
  +            input.setObjectPart("name", "John Smith");
  +
  +            // do the invocation
  +            System.out.println("Querying address for John Smith...");
  +            if (operation.executeRequestResponseOperation(input, output, fault)) {
  +                // invocation succeeded
  +                // extract the address from the output message
  +                Address address = (Address) output.getObjectPart("address");
  +                System.out.println("Service returned the following address:");
  +                System.out.println(
  +                    address.getStreetNum()
  +                        + " "
  +                        + address.getStreetName()
  +                        + ", "
  +                        + address.getCity()
  +                        + " "
  +                        + address.getState()
  +                        + " "
  +                        + address.getZip()
  +                        + "; Phone: ("
  +                        + address.getPhoneNumber().getAreaCode()
  +                        + ") "
  +                        + address.getPhoneNumber().getExchange()
  +                        + "-"
  +                        + address.getPhoneNumber().getNumber());
  +            } else {
  +                // invocation failed, check fault message
  +            }
  + 
  +            // create the operation
  +            operation = port.createOperation("getAddressFromName");
  + 
  +            // create the input message associated with this operation
  +            input = operation.createInputMessage();
  +            output = operation.createOutputMessage();
  +            fault = operation.createFaultMessage();
  + 
  +            // populate the input message
  +            input.setObjectPart("name", "Jane White");
  + 
  +            // do the invocation
  +            System.out.println("Querying address for Jane White...");
  +            if (operation.executeRequestResponseOperation(input, output, fault)) {
  +                // invocation succeeded
  +                // extract the address from the output message
  +                Address address = (Address) output.getObjectPart("address");
  +                System.out.println("Service returned the following address:");
  +                System.out.println(
  +                    address.getStreetNum()
  +                        + " "
  +                        + address.getStreetName()
  +                        + ", "
  +                        + address.getCity()
  +                        + " "
  +                        + address.getState()
  +                        + " "
  +                        + address.getZip()
  +                        + "; Phone: ("
  +                        + address.getPhoneNumber().getAreaCode()
  +                        + ") "
  +                        + address.getPhoneNumber().getExchange()
  +                        + "-"
  +                        + address.getPhoneNumber().getNumber());
  +            } else {
  +                // invocation failed, check fault message
  +            }
  +        } catch (WSIFException we) {
  +            System.out.println("Got exception from WSIF, details:");
  +            we.printStackTrace();
  +        }
       }
   
  -    public static void main(String [] args) throws Exception {
  -     if(args.length!=1) {
  -         System.out.println("Usage: java samples.java.client.dynamic.Run <wsdl 
location>");
  -         System.exit(1);
  -     }
  -     // create a service factory
  +    public static void main(String[] args) throws Exception {
  +        if (args.length != 1) {
  +            System.out.println(
  +                "Usage: java samples.java.client.dynamic.Run <wsdl location>");
  +            System.exit(1);
  +        }
  +
  +        // create a service factory
           WSIFServiceFactory factory = WSIFServiceFactory.newInstance();
  -     
  -     WSIFService service = factory.getService(args[0], null,
  -                                              null, 
"http://wsifservice.addressbook/";, 
  -                                              "AddressBook"); 
  -     // map types
  -     service.mapType(new QName("http://wsiftypes.addressbook/","Address";),
  -                     Class.forName("addressbook.wsiftypes.Address"));
  -     service.mapType(new QName("http://wsiftypes.addressbook/","Phone";),
  -                     Class.forName("addressbook.wsiftypes.Phone"));
  -
  -     // get the port
  -     WSIFPort port = service.getPort();
  -     // add the first address
  -     addFirstAddress(port);
  -     // add the second address
  -     addSecondAddress(port);
  -     // query addresses
  -     queryAddresses(port);
  +        WSIFService service =
  +            factory.getService(
  +                args[0],
  +                null,
  +                null,
  +                "http://wsifservice.addressbook/";,
  +                "AddressBook");
  +
  +        // map types
  +        service.mapType(
  +            new QName("http://wsiftypes.addressbook/";, "Address"),
  +            Class.forName("addressbook.wsiftypes.Address"));
  +        service.mapType(
  +            new QName("http://wsiftypes.addressbook/";, "Phone"),
  +            Class.forName("addressbook.wsiftypes.Phone"));
  +
  +        // get the port
  +        WSIFPort port = service.getPort();
  +
  +        // add the first address
  +        addFirstAddress(port);
  +
  +        // add the second address
  +        addSecondAddress(port);
  +
  +        // query addresses
  +        queryAddresses(port);
       }
   }
  
  
  


Reply via email to