axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/samples/userguide/example5 BeanService.java Client.java Order.java deploy.xml
Date Fri, 03 Aug 2001 21:12:14 GMT
gdaniels    01/08/03 14:12:14

  Added:       java/samples/userguide/example5 BeanService.java Client.java
                        Order.java deploy.xml
  Log:
  More examples
  
  Revision  Changes    Path
  1.1                  xml-axis/java/samples/userguide/example5/BeanService.java
  
  Index: BeanService.java
  ===================================================================
  
  public class BeanService
  {
      public String processOrder(Order order)
      {
          String sep = System.getProperty("line.separator");
          
          String response = "Hi, " + order.getCustomerName() + "!" + sep;
          
          response += sep + "You seem to have ordered the following:" + sep;
          
          String [] items = order.getItemCodes();
          int [] quantities = order.getQuantities();
          
          for (int i = 0; i < items.length; i++) {
              response += sep + quantities[i] + " of item : " + items[i];
          }
          
          response += sep + sep +
                      "If this had been a real order processing system, "+
                      "we'd probably have charged you about now.";
          
          return response;
      }
  }
  
  
  
  1.1                  xml-axis/java/samples/userguide/example5/Client.java
  
  Index: Client.java
  ===================================================================
  import org.apache.axis.AxisFault;
  import org.apache.axis.client.ServiceClient;
  import org.apache.axis.utils.Options;
  import org.apache.axis.utils.QName;
                                             
  public class Client
  {
      public static void main(String [] args) throws Exception
      {
          Options options = new Options(args);
          
          Order order = new Order();
          order.setCustomerName("Glen Daniels");
          order.setShippingAddress("275 Grove Street, Newton, MA");
          
          String [] items = new String[] { "mp3jukebox", "1600mahBattery" };
          int [] quantities = new int [] { 1, 4 };
          
          order.setItemCodes(items);
          order.setQuantities(quantities);
          
          ServiceClient client = new ServiceClient(options.getURL());
          client.addSerializer(Order.class, new QName("urn:BeanService", "Order"),
                               new org.apache.axis.encoding.BeanSerializer(Order.class));
          
          String result;
          try {
              result = (String)client.invoke("OrderProcessor",
                                             "processOrder",
                                             new Object[] { order });
          } catch (AxisFault fault) {
              result = "Error : " + fault.toString();
          }
          
          System.out.println(result);
      }
  }
  
  
  
  1.1                  xml-axis/java/samples/userguide/example5/Order.java
  
  Index: Order.java
  ===================================================================
  
  /** This is a JavaBean which represents an order for some products.
   * 
   * @author Glen Daniels (gdaniels@macromedia.com)
   */
  public class Order
  {
      /** Who's ordering  */
      private String customerName;
      /** Where do they live  */
      private String shippingAddress;
      /** Which items do we want */
      private String itemCodes[];
      /** And how many */
      private int quantities[];
      
      // Bean accessors
      
      public String getCustomerName()
      { return customerName; }
      public void setCustomerName(String name)
      { customerName = name; }
      
      public String getShippingAddress()
      { return shippingAddress; }
      public void setShippingAddress(String address)
      { shippingAddress = address; }
      
      public String [] getItemCodes()
      { return itemCodes; }
      public void setItemCodes(String [] items)
      { itemCodes = items; }
      
      public int [] getQuantities()
      { return quantities; }
      public void setQuantities(int [] quants)
      { quantities = quants; }
  }
  
  
  
  1.1                  xml-axis/java/samples/userguide/example5/deploy.xml
  
  Index: deploy.xml
  ===================================================================
  <m:deploy xmlns:m="AdminService">
   <service name="OrderProcessor" pivot="RPCDispatcher">
    <option name="className" value="BeanService"/>
    <option name="methodName" value="processOrder"/>
    <beanMappings>
     <myNS:order xmlns:myNS="urn:BeanService" classname="Order"/>
    </beanMappings>
   </service>
  </m:deploy>
  
  
  

Mime
View raw message