You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@xml.apache.org by du...@apache.org on 2001/05/25 21:04:36 UTC

cvs commit: xml-soap/java/samples/bidbuy/shared Address.java AddressSerializer.java LineItem.java LineItemSerializer.java PurchaseOrder.java PurchaseOrderSerializer.java Service.java ServiceSerializer.java

duftler     01/05/25 12:04:36

  Added:       java/samples/bidbuy/shared Address.java
                        AddressSerializer.java LineItem.java
                        LineItemSerializer.java PurchaseOrder.java
                        PurchaseOrderSerializer.java Service.java
                        ServiceSerializer.java
  Log:
  Added BidBuy interop sample.
  The non-ApacheSOAP specific code was taken from Axis. (With pointers and
    help from Doug Davis).
  The Apache SOAP specific code was written by me (Matt Duftler).
  The documentation was written by Bill Nagy.
  
  Revision  Changes    Path
  1.1                  xml-soap/java/samples/bidbuy/shared/Address.java
  
  Index: Address.java
  ===================================================================
  package samples.bidbuy.shared;
  
  public class Address {
  
      // constructors
  
      public Address() {};
  
      public Address(String name, String address, String city, String state,
                     String zipCode)
      {
           this.name=name;
           this.address=address;
           this.city=city;
           this.state=state;
           this.zipCode=zipCode;
      }
      
      // properties
  
      private String name;
      public String getName() { return name; }
      public void setName(String value) { name=value; }
  
      private String address;
      public String getAddress() { return address; }
      public void setAddress(String value) { address=value; }
  
      private String city;
      public String getCity() { return city; }
      public void setCity(String value) { city=value; }
  
      private String state;
      public String getState() { return state; }
      public void setState(String value) { state=value; }
  
      private String zipCode;
      public String getZipCode() { return zipCode; }
      public void setZipCode(String value) { zipCode=value; }
  
      public String toString()
      {
        StringBuffer strBuf = new StringBuffer();
  
        strBuf.append(name + '\n');
        strBuf.append(address + '\n');
        strBuf.append(city + ", " + state + "  " + zipCode + '\n');
  
        return strBuf.toString();
      }
  }
  
  
  
  1.1                  xml-soap/java/samples/bidbuy/shared/AddressSerializer.java
  
  Index: AddressSerializer.java
  ===================================================================
  package samples.bidbuy.shared;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  
  /**
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class AddressSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);
  
      sink.write(StringUtils.lineSeparator);
  
      Address addr = (Address)src;
      String name = addr.getName();
      String address = addr.getAddress();
      String city = addr.getCity();
      String state = addr.getState();
      String zipCode = addr.getZipCode();
  
      if (name != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      name,
                      "name",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (address != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      address,
                      "address",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (city != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      city,
                      "city",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (state != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      state,
                      "state",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (zipCode != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      zipCode,
                      "zipCode",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      sink.write("</" + context + '>');
  
      nsStack.popScope();
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException
    {
      Element addrElement = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(addrElement);
      Address addr = new Address();
  
      while (tempEl != null)
      {
        String tagName = tempEl.getTagName();
  
        if (tagName.equals("name"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          addr.setName((String)param.getValue());
        }
        else if (tagName.equals("address"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          addr.setAddress((String)param.getValue());
        }
        else if (tagName.equals("city"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          addr.setCity((String)param.getValue());
        }
        else if (tagName.equals("state"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          addr.setState((String)param.getValue());
        }
        else if (tagName.equals("zipCode"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          addr.setZipCode((String)param.getValue());
        }
  
        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }
  
      return new Bean(Address.class, addr);
    }
  }
  
  
  
  1.1                  xml-soap/java/samples/bidbuy/shared/LineItem.java
  
  Index: LineItem.java
  ===================================================================
  package samples.bidbuy.shared;
  
  import java.math.BigDecimal;
  
  public class LineItem {
  
      // constructors
  
      public LineItem() {};
  
      public LineItem(String name, int quantity, BigDecimal price) {
           this.name=name;
           this.quantity=quantity;
           this.price=price;
      }
  
      public LineItem(String name, int quantity, String price) {
           this.name=name;
           this.quantity=quantity;
           this.price=new BigDecimal(price);
      }
  
      // properties
  
      private String name;
      public String getName() { return name; }
      public void setName(String value) { name=value; }
  
      private int quantity;
      public int getQuantity() { return quantity; }
      public void setQuantity(int value) { quantity=value; }
  
      private BigDecimal price;
      public BigDecimal getPrice() { return price; }
      public void setPrice(BigDecimal value) { price=value; }
  
      public String toString()
      {
        return "Name=" + name + "  Quantity=" + quantity + "  Price=$" + price;
      }
  }
  
  
  
  1.1                  xml-soap/java/samples/bidbuy/shared/LineItemSerializer.java
  
  Index: LineItemSerializer.java
  ===================================================================
  package samples.bidbuy.shared;
  
  import java.io.*;
  import java.math.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  
  /**
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class LineItemSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);
  
      sink.write(StringUtils.lineSeparator);
  
      LineItem lineItem = (LineItem)src;
      String name = lineItem.getName();
      int quantity = lineItem.getQuantity();
      BigDecimal price = lineItem.getPrice();
  
      if (name != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      name,
                      "name",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      xjmr.marshall(inScopeEncStyle,
                    int.class,
                    new Integer(quantity),
                    "quantity",
                    sink,
                    nsStack,
                    ctx);
  
      sink.write(StringUtils.lineSeparator);
  
      if (price != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      BigDecimal.class,
                      price,
                      "price",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      sink.write("</" + context + '>');
  
      nsStack.popScope();
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException
    {
      Element lineItemElement = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(lineItemElement);
      LineItem lineItem = new LineItem();
  
      while (tempEl != null)
      {
        String tagName = tempEl.getTagName();
  
        if (tagName.equals("name"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          lineItem.setName((String)param.getValue());
        }
        else if (tagName.equals("quantity"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          lineItem.setQuantity(((Integer)param.getValue()).intValue());
        }
        else if (tagName.equals("price"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          lineItem.setPrice((BigDecimal)param.getValue());
        }
  
        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }
  
      return new Bean(LineItem.class, lineItem);
    }
  }
  
  
  
  1.1                  xml-soap/java/samples/bidbuy/shared/PurchaseOrder.java
  
  Index: PurchaseOrder.java
  ===================================================================
  package samples.bidbuy.shared;
  
  import java.util.Date;
  
  public class PurchaseOrder {
  
      // constructors
  
      public PurchaseOrder() {};
  
      public PurchaseOrder(String id, Date createDate, Address shipTo,
                           Address billTo, LineItem[] items)
      {
           this.poID=id;
           this.createDate=createDate;
           this.shipTo=shipTo;
           this.billTo=billTo;
           this.items=items;
      }
      
      // properties
  
      private String poID;
      public String getPoID() { return poID; }
      public void setPoID(String value) { poID=value; }
  
      private Date createDate;
      public Date getCreateDate() { return createDate; }
      public void setCreateDate(Date value) { createDate=value; }
  
      private Address shipTo;
      public Address getShipTo() { return shipTo; }
      public void setShipTo(Address value) { shipTo=value; }
  
      private Address billTo;
      public Address getBillTo() { return billTo; }
      public void setBillTo(Address value) { billTo=value; }
  
      private LineItem[] items;
      public LineItem[] getItems() { return items; }
      public void setItems(LineItem[] value) { items=value; }
  
      public String toString()
      {
        StringBuffer strBuf = new StringBuffer();
  
        strBuf.append("Purchase Order ID: " + poID + '\n');
        strBuf.append("Creation Date: " + createDate + "\n\n");
        strBuf.append("Ship To\n=======\n" + shipTo + '\n');
        strBuf.append("Bill To\n=======\n" + billTo + '\n');
        strBuf.append("Items\n=====\n");
  
        if (items != null)
        {
          for (int i = 0; i < items.length; i++)
          {
            strBuf.append("Item #" + (i+1) + ": " + items[i] + '\n');
          }
        }
  
        return strBuf.toString();
      }
  }
    
  
  
  1.1                  xml-soap/java/samples/bidbuy/shared/PurchaseOrderSerializer.java
  
  Index: PurchaseOrderSerializer.java
  ===================================================================
  package samples.bidbuy.shared;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import samples.bidbuy.shared.*;
  
  /**
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class PurchaseOrderSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);
  
      sink.write(StringUtils.lineSeparator);
  
      PurchaseOrder po = (PurchaseOrder)src;
      String poID = po.getPoID();
      Date createDate = po.getCreateDate();
      Address shipTo = po.getShipTo();
      Address billTo = po.getBillTo();
      LineItem[] items = po.getItems();
  
      if (poID != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      poID,
                      "poID",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (createDate != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      Date.class,
                      createDate,
                      "createDate",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (shipTo != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      Address.class,
                      shipTo,
                      "shipTo",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (billTo != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      Address.class,
                      billTo,
                      "billTo",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (items != null)
      {
        Parameter param = new Parameter("items",
                                        LineItem[].class,
                                        items,
                                        null);
  
        xjmr.marshall(inScopeEncStyle,
                      Parameter.class,
                      param,
                      null,
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      sink.write("</" + context + '>');
  
      nsStack.popScope();
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException
    {
      Element poElement = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(poElement);
      PurchaseOrder po = new PurchaseOrder();
  
      while (tempEl != null)
      {
        String tagName = tempEl.getTagName();
  
        if (tagName.equals("poID"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          po.setPoID((String)param.getValue());
        }
        else if (tagName.equals("createDate"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          po.setCreateDate((Date)param.getValue());
        }
        else if (tagName.equals("shipTo"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          po.setShipTo((Address)param.getValue());
        }
        else if (tagName.equals("billTo"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          po.setBillTo((Address)param.getValue());
        }
        else if (tagName.equals("items"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          po.setItems((LineItem[])param.getValue());
        }
  
        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }
  
      System.err.println("Returning: " + po);
  
      return new Bean(PurchaseOrder.class, po);
    }
  }
  
  
  
  1.1                  xml-soap/java/samples/bidbuy/shared/Service.java
  
  Index: Service.java
  ===================================================================
  package samples.bidbuy.shared;
  
  public class Service implements java.io.Serializable {
      private String ServiceName;
      private String ServiceUrl;
      private String ServiceType;
      private String ServiceWsdl;
  
      public String getServiceName() {
         return ServiceName;
      }
  
      public void setServiceName(String value) {
         ServiceName = value;
      }
  
      public String getServiceUrl() {
         return ServiceUrl;
      }
  
      public void setServiceUrl(String value) {
         ServiceUrl = value;
      }
  
      public String getServiceType() {
         return ServiceType;
      }
  
      public void setServiceType(String value) {
         ServiceType = value;
      }
  
      public String getServiceWsdl() {
         return ServiceWsdl;
      }
  
      public void setServiceWsdl(String value) {
         ServiceWsdl = value;
      }
  }
  
  
  
  1.1                  xml-soap/java/samples/bidbuy/shared/ServiceSerializer.java
  
  Index: ServiceSerializer.java
  ===================================================================
  package samples.bidbuy.shared;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  
  /**
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class ServiceSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);
  
      sink.write(StringUtils.lineSeparator);
  
      Service svc = (Service)src;
      String serviceName = svc.getServiceName();
      String serviceUrl = svc.getServiceUrl();
      String serviceType = svc.getServiceType();
      String serviceWsdl = svc.getServiceWsdl();
  
      if (serviceName != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      serviceName,
                      "serviceName",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (serviceUrl != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      serviceUrl,
                      "serviceUrl",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (serviceType != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      serviceType,
                      "serviceType",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      if (serviceWsdl != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      serviceWsdl,
                      "serviceWsdl",
                      sink,
                      nsStack,
                      ctx);
  
        sink.write(StringUtils.lineSeparator);
      }
  
      sink.write("</" + context + '>');
  
      nsStack.popScope();
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException
    {
      Element svcElement = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(svcElement);
      Service svc = new Service();
  
      while (tempEl != null)
      {
        String tagName = tempEl.getTagName();
  
        if (tagName.equals("serviceName"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          svc.setServiceName((String)param.getValue());
        }
        else if (tagName.equals("serviceUrl"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          svc.setServiceUrl((String)param.getValue());
        }
        else if (tagName.equals("serviceType"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          svc.setServiceType((String)param.getValue());
        }
        else if (tagName.equals("serviceWsdl"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;
  
          svc.setServiceWsdl((String)param.getValue());
        }
  
        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }
  
      return new Bean(Service.class, svc);
    }
  }
  
  
  

Re: Unsubscribe Me, Please

Posted by Rob Jellinghaus <ro...@unrealities.com>.
Can you please look at the headers of ANY MESSAGE POSTED TO THE LIST:

list-help: <ma...@xml.apache.org>
list-unsubscribe: <ma...@xml.apache.org>
list-post: <ma...@xml.apache.org>

and do it yourself!

Cheers,
Rob


At 02:20 PM 5/25/2001 -0600, you wrote:
>Can you please unsubscribe me from this address. Thank you.
>
>-----Original Message-----
>From: duftler@apache.org [mailto:duftler@apache.org]
>Sent: Friday, May 25, 2001 1:05 PM
>To: xml-soap-cvs@apache.org
>Subject: cvs commit: xml-soap/java/samples/bidbuy/shared Address.java
>AddressSerializer.java LineItem.java LineItemSerializer.java
>PurchaseOrder.java PurchaseOrderSerializer.java Service.java
>ServiceSerializer.java
>
>
>duftler     01/05/25 12:04:36
>
>  Added:       java/samples/bidbuy/shared Address.java
>                        AddressSerializer.java LineItem.java
>                        LineItemSerializer.java PurchaseOrder.java
>                        PurchaseOrderSerializer.java Service.java
>                        ServiceSerializer.java
>  Log:
>  Added BidBuy interop sample.
>  The non-ApacheSOAP specific code was taken from Axis. (With pointers and
>    help from Doug Davis).
>  The Apache SOAP specific code was written by me (Matt Duftler).
>  The documentation was written by Bill Nagy.
>
>  Revision  Changes    Path
>  1.1                  xml-soap/java/samples/bidbuy/shared/Address.java
>
>  Index: Address.java
>  ===================================================================
>  package samples.bidbuy.shared;
>
>  public class Address {
>
>      // constructors
>
>      public Address() {};
>
>      public Address(String name, String address, String city, String state,
>                     String zipCode)
>      {
>           this.name=name;
>           this.address=address;
>           this.city=city;
>           this.state=state;
>           this.zipCode=zipCode;
>      }
>
>      // properties
>
>      private String name;
>      public String getName() { return name; }
>      public void setName(String value) { name=value; }
>
>      private String address;
>      public String getAddress() { return address; }
>      public void setAddress(String value) { address=value; }
>
>      private String city;
>      public String getCity() { return city; }
>      public void setCity(String value) { city=value; }
>
>      private String state;
>      public String getState() { return state; }
>      public void setState(String value) { state=value; }
>
>      private String zipCode;
>      public String getZipCode() { return zipCode; }
>      public void setZipCode(String value) { zipCode=value; }
>
>      public String toString()
>      {
>        StringBuffer strBuf = new StringBuffer();
>
>        strBuf.append(name + '\n');
>        strBuf.append(address + '\n');
>        strBuf.append(city + ", " + state + "  " + zipCode + '\n');
>
>        return strBuf.toString();
>      }
>  }
>
>
>
>  1.1
>xml-soap/java/samples/bidbuy/shared/AddressSerializer.java
>
>  Index: AddressSerializer.java
>  ===================================================================
>  package samples.bidbuy.shared;
>
>  import java.io.*;
>  import java.util.*;
>  import org.w3c.dom.*;
>  import org.apache.soap.*;
>  import org.apache.soap.encoding.soapenc.*;
>  import org.apache.soap.rpc.*;
>  import org.apache.soap.util.*;
>  import org.apache.soap.util.xml.*;
>
>  /**
>   * @author Matthew J. Duftler (duftler@us.ibm.com)
>   */
>  public class AddressSerializer implements Serializer, Deserializer
>  {
>    public void marshall(String inScopeEncStyle, Class javaType, Object src,
>                         Object context, Writer sink, NSStack nsStack,
>                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>      throws IllegalArgumentException, IOException
>    {
>      nsStack.pushScope();
>
>      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
>                                           javaType,
>                                           context,
>                                           sink,
>                                           nsStack,
>                                           xjmr);
>
>      sink.write(StringUtils.lineSeparator);
>
>      Address addr = (Address)src;
>      String name = addr.getName();
>      String address = addr.getAddress();
>      String city = addr.getCity();
>      String state = addr.getState();
>      String zipCode = addr.getZipCode();
>
>      if (name != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      name,
>                      "name",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (address != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      address,
>                      "address",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (city != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      city,
>                      "city",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (state != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      state,
>                      "state",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (zipCode != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      zipCode,
>                      "zipCode",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      sink.write("</" + context + '>');
>
>      nsStack.popScope();
>    }
>
>    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
>src,
>                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>      throws IllegalArgumentException
>    {
>      Element addrElement = (Element)src;
>      Element tempEl = DOMUtils.getFirstChildElement(addrElement);
>      Address addr = new Address();
>
>      while (tempEl != null)
>      {
>        String tagName = tempEl.getTagName();
>
>        if (tagName.equals("name"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          addr.setName((String)param.getValue());
>        }
>        else if (tagName.equals("address"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          addr.setAddress((String)param.getValue());
>        }
>        else if (tagName.equals("city"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          addr.setCity((String)param.getValue());
>        }
>        else if (tagName.equals("state"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          addr.setState((String)param.getValue());
>        }
>        else if (tagName.equals("zipCode"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          addr.setZipCode((String)param.getValue());
>        }
>
>        tempEl = DOMUtils.getNextSiblingElement(tempEl);
>      }
>
>      return new Bean(Address.class, addr);
>    }
>  }
>
>
>
>  1.1                  xml-soap/java/samples/bidbuy/shared/LineItem.java
>
>  Index: LineItem.java
>  ===================================================================
>  package samples.bidbuy.shared;
>
>  import java.math.BigDecimal;
>
>  public class LineItem {
>
>      // constructors
>
>      public LineItem() {};
>
>      public LineItem(String name, int quantity, BigDecimal price) {
>           this.name=name;
>           this.quantity=quantity;
>           this.price=price;
>      }
>
>      public LineItem(String name, int quantity, String price) {
>           this.name=name;
>           this.quantity=quantity;
>           this.price=new BigDecimal(price);
>      }
>
>      // properties
>
>      private String name;
>      public String getName() { return name; }
>      public void setName(String value) { name=value; }
>
>      private int quantity;
>      public int getQuantity() { return quantity; }
>      public void setQuantity(int value) { quantity=value; }
>
>      private BigDecimal price;
>      public BigDecimal getPrice() { return price; }
>      public void setPrice(BigDecimal value) { price=value; }
>
>      public String toString()
>      {
>        return "Name=" + name + "  Quantity=" + quantity + "  Price=$" +
>price;
>      }
>  }
>
>
>
>  1.1
>xml-soap/java/samples/bidbuy/shared/LineItemSerializer.java
>
>  Index: LineItemSerializer.java
>  ===================================================================
>  package samples.bidbuy.shared;
>
>  import java.io.*;
>  import java.math.*;
>  import java.util.*;
>  import org.w3c.dom.*;
>  import org.apache.soap.*;
>  import org.apache.soap.encoding.soapenc.*;
>  import org.apache.soap.rpc.*;
>  import org.apache.soap.util.*;
>  import org.apache.soap.util.xml.*;
>
>  /**
>   * @author Matthew J. Duftler (duftler@us.ibm.com)
>   */
>  public class LineItemSerializer implements Serializer, Deserializer
>  {
>    public void marshall(String inScopeEncStyle, Class javaType, Object src,
>                         Object context, Writer sink, NSStack nsStack,
>                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>      throws IllegalArgumentException, IOException
>    {
>      nsStack.pushScope();
>
>      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
>                                           javaType,
>                                           context,
>                                           sink,
>                                           nsStack,
>                                           xjmr);
>
>      sink.write(StringUtils.lineSeparator);
>
>      LineItem lineItem = (LineItem)src;
>      String name = lineItem.getName();
>      int quantity = lineItem.getQuantity();
>      BigDecimal price = lineItem.getPrice();
>
>      if (name != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      name,
>                      "name",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      xjmr.marshall(inScopeEncStyle,
>                    int.class,
>                    new Integer(quantity),
>                    "quantity",
>                    sink,
>                    nsStack,
>                    ctx);
>
>      sink.write(StringUtils.lineSeparator);
>
>      if (price != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      BigDecimal.class,
>                      price,
>                      "price",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      sink.write("</" + context + '>');
>
>      nsStack.popScope();
>    }
>
>    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
>src,
>                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>      throws IllegalArgumentException
>    {
>      Element lineItemElement = (Element)src;
>      Element tempEl = DOMUtils.getFirstChildElement(lineItemElement);
>      LineItem lineItem = new LineItem();
>
>      while (tempEl != null)
>      {
>        String tagName = tempEl.getTagName();
>
>        if (tagName.equals("name"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          lineItem.setName((String)param.getValue());
>        }
>        else if (tagName.equals("quantity"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          lineItem.setQuantity(((Integer)param.getValue()).intValue());
>        }
>        else if (tagName.equals("price"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          lineItem.setPrice((BigDecimal)param.getValue());
>        }
>
>        tempEl = DOMUtils.getNextSiblingElement(tempEl);
>      }
>
>      return new Bean(LineItem.class, lineItem);
>    }
>  }
>
>
>
>  1.1
>xml-soap/java/samples/bidbuy/shared/PurchaseOrder.java
>
>  Index: PurchaseOrder.java
>  ===================================================================
>  package samples.bidbuy.shared;
>
>  import java.util.Date;
>
>  public class PurchaseOrder {
>
>      // constructors
>
>      public PurchaseOrder() {};
>
>      public PurchaseOrder(String id, Date createDate, Address shipTo,
>                           Address billTo, LineItem[] items)
>      {
>           this.poID=id;
>           this.createDate=createDate;
>           this.shipTo=shipTo;
>           this.billTo=billTo;
>           this.items=items;
>      }
>
>      // properties
>
>      private String poID;
>      public String getPoID() { return poID; }
>      public void setPoID(String value) { poID=value; }
>
>      private Date createDate;
>      public Date getCreateDate() { return createDate; }
>      public void setCreateDate(Date value) { createDate=value; }
>
>      private Address shipTo;
>      public Address getShipTo() { return shipTo; }
>      public void setShipTo(Address value) { shipTo=value; }
>
>      private Address billTo;
>      public Address getBillTo() { return billTo; }
>      public void setBillTo(Address value) { billTo=value; }
>
>      private LineItem[] items;
>      public LineItem[] getItems() { return items; }
>      public void setItems(LineItem[] value) { items=value; }
>
>      public String toString()
>      {
>        StringBuffer strBuf = new StringBuffer();
>
>        strBuf.append("Purchase Order ID: " + poID + '\n');
>        strBuf.append("Creation Date: " + createDate + "\n\n");
>        strBuf.append("Ship To\n=======\n" + shipTo + '\n');
>        strBuf.append("Bill To\n=======\n" + billTo + '\n');
>        strBuf.append("Items\n=====\n");
>
>        if (items != null)
>        {
>          for (int i = 0; i < items.length; i++)
>          {
>            strBuf.append("Item #" + (i+1) + ": " + items[i] + '\n');
>          }
>        }
>
>        return strBuf.toString();
>      }
>  }
>
>
>
>  1.1                  xml-soap/java/samples/bidbuy/shared/PurchaseOrderSeri
>alizer.java
>
>  Index: PurchaseOrderSerializer.java
>  ===================================================================
>  package samples.bidbuy.shared;
>
>  import java.io.*;
>  import java.util.*;
>  import org.w3c.dom.*;
>  import org.apache.soap.*;
>  import org.apache.soap.encoding.soapenc.*;
>  import org.apache.soap.rpc.*;
>  import org.apache.soap.util.*;
>  import org.apache.soap.util.xml.*;
>  import samples.bidbuy.shared.*;
>
>  /**
>   * @author Matthew J. Duftler (duftler@us.ibm.com)
>   */
>  public class PurchaseOrderSerializer implements Serializer, Deserializer
>  {
>    public void marshall(String inScopeEncStyle, Class javaType, Object src,
>                         Object context, Writer sink, NSStack nsStack,
>                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>      throws IllegalArgumentException, IOException
>    {
>      nsStack.pushScope();
>
>      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
>                                           javaType,
>                                           context,
>                                           sink,
>                                           nsStack,
>                                           xjmr);
>
>      sink.write(StringUtils.lineSeparator);
>
>      PurchaseOrder po = (PurchaseOrder)src;
>      String poID = po.getPoID();
>      Date createDate = po.getCreateDate();
>      Address shipTo = po.getShipTo();
>      Address billTo = po.getBillTo();
>      LineItem[] items = po.getItems();
>
>      if (poID != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      poID,
>                      "poID",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (createDate != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      Date.class,
>                      createDate,
>                      "createDate",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (shipTo != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      Address.class,
>                      shipTo,
>                      "shipTo",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (billTo != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      Address.class,
>                      billTo,
>                      "billTo",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (items != null)
>      {
>        Parameter param = new Parameter("items",
>                                        LineItem[].class,
>                                        items,
>                                        null);
>
>        xjmr.marshall(inScopeEncStyle,
>                      Parameter.class,
>                      param,
>                      null,
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      sink.write("</" + context + '>');
>
>      nsStack.popScope();
>    }
>
>    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
>src,
>                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>      throws IllegalArgumentException
>    {
>      Element poElement = (Element)src;
>      Element tempEl = DOMUtils.getFirstChildElement(poElement);
>      PurchaseOrder po = new PurchaseOrder();
>
>      while (tempEl != null)
>      {
>        String tagName = tempEl.getTagName();
>
>        if (tagName.equals("poID"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          po.setPoID((String)param.getValue());
>        }
>        else if (tagName.equals("createDate"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          po.setCreateDate((Date)param.getValue());
>        }
>        else if (tagName.equals("shipTo"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          po.setShipTo((Address)param.getValue());
>        }
>        else if (tagName.equals("billTo"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          po.setBillTo((Address)param.getValue());
>        }
>        else if (tagName.equals("items"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          po.setItems((LineItem[])param.getValue());
>        }
>
>        tempEl = DOMUtils.getNextSiblingElement(tempEl);
>      }
>
>      System.err.println("Returning: " + po);
>
>      return new Bean(PurchaseOrder.class, po);
>    }
>  }
>
>
>
>  1.1                  xml-soap/java/samples/bidbuy/shared/Service.java
>
>  Index: Service.java
>  ===================================================================
>  package samples.bidbuy.shared;
>
>  public class Service implements java.io.Serializable {
>      private String ServiceName;
>      private String ServiceUrl;
>      private String ServiceType;
>      private String ServiceWsdl;
>
>      public String getServiceName() {
>         return ServiceName;
>      }
>
>      public void setServiceName(String value) {
>         ServiceName = value;
>      }
>
>      public String getServiceUrl() {
>         return ServiceUrl;
>      }
>
>      public void setServiceUrl(String value) {
>         ServiceUrl = value;
>      }
>
>      public String getServiceType() {
>         return ServiceType;
>      }
>
>      public void setServiceType(String value) {
>         ServiceType = value;
>      }
>
>      public String getServiceWsdl() {
>         return ServiceWsdl;
>      }
>
>      public void setServiceWsdl(String value) {
>         ServiceWsdl = value;
>      }
>  }
>
>
>
>  1.1
>xml-soap/java/samples/bidbuy/shared/ServiceSerializer.java
>
>  Index: ServiceSerializer.java
>  ===================================================================
>  package samples.bidbuy.shared;
>
>  import java.io.*;
>  import java.util.*;
>  import org.w3c.dom.*;
>  import org.apache.soap.*;
>  import org.apache.soap.encoding.soapenc.*;
>  import org.apache.soap.rpc.*;
>  import org.apache.soap.util.*;
>  import org.apache.soap.util.xml.*;
>
>  /**
>   * @author Matthew J. Duftler (duftler@us.ibm.com)
>   */
>  public class ServiceSerializer implements Serializer, Deserializer
>  {
>    public void marshall(String inScopeEncStyle, Class javaType, Object src,
>                         Object context, Writer sink, NSStack nsStack,
>                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>      throws IllegalArgumentException, IOException
>    {
>      nsStack.pushScope();
>
>      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
>                                           javaType,
>                                           context,
>                                           sink,
>                                           nsStack,
>                                           xjmr);
>
>      sink.write(StringUtils.lineSeparator);
>
>      Service svc = (Service)src;
>      String serviceName = svc.getServiceName();
>      String serviceUrl = svc.getServiceUrl();
>      String serviceType = svc.getServiceType();
>      String serviceWsdl = svc.getServiceWsdl();
>
>      if (serviceName != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      serviceName,
>                      "serviceName",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (serviceUrl != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      serviceUrl,
>                      "serviceUrl",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (serviceType != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      serviceType,
>                      "serviceType",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      if (serviceWsdl != null)
>      {
>        xjmr.marshall(inScopeEncStyle,
>                      String.class,
>                      serviceWsdl,
>                      "serviceWsdl",
>                      sink,
>                      nsStack,
>                      ctx);
>
>        sink.write(StringUtils.lineSeparator);
>      }
>
>      sink.write("</" + context + '>');
>
>      nsStack.popScope();
>    }
>
>    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
>src,
>                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
>      throws IllegalArgumentException
>    {
>      Element svcElement = (Element)src;
>      Element tempEl = DOMUtils.getFirstChildElement(svcElement);
>      Service svc = new Service();
>
>      while (tempEl != null)
>      {
>        String tagName = tempEl.getTagName();
>
>        if (tagName.equals("serviceName"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          svc.setServiceName((String)param.getValue());
>        }
>        else if (tagName.equals("serviceUrl"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          svc.setServiceUrl((String)param.getValue());
>        }
>        else if (tagName.equals("serviceType"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          svc.setServiceType((String)param.getValue());
>        }
>        else if (tagName.equals("serviceWsdl"))
>        {
>          Bean bean = xjmr.unmarshall(inScopeEncStyle,
>                                      RPCConstants.Q_ELEM_PARAMETER,
>                                      tempEl,
>                                      ctx);
>          Parameter param = (Parameter)bean.value;
>
>          svc.setServiceWsdl((String)param.getValue());
>        }
>
>        tempEl = DOMUtils.getNextSiblingElement(tempEl);
>      }
>
>      return new Bean(Service.class, svc);
>    }
>  }
>
>
>
>
>
>
>
>


Unsubscribe Me, Please

Posted by Adnan Fida <af...@point2.com>.
Can you please unsubscribe me from this address. Thank you.

-----Original Message-----
From: duftler@apache.org [mailto:duftler@apache.org]
Sent: Friday, May 25, 2001 1:05 PM
To: xml-soap-cvs@apache.org
Subject: cvs commit: xml-soap/java/samples/bidbuy/shared Address.java
AddressSerializer.java LineItem.java LineItemSerializer.java
PurchaseOrder.java PurchaseOrderSerializer.java Service.java
ServiceSerializer.java


duftler     01/05/25 12:04:36

  Added:       java/samples/bidbuy/shared Address.java
                        AddressSerializer.java LineItem.java
                        LineItemSerializer.java PurchaseOrder.java
                        PurchaseOrderSerializer.java Service.java
                        ServiceSerializer.java
  Log:
  Added BidBuy interop sample.
  The non-ApacheSOAP specific code was taken from Axis. (With pointers and
    help from Doug Davis).
  The Apache SOAP specific code was written by me (Matt Duftler).
  The documentation was written by Bill Nagy.

  Revision  Changes    Path
  1.1                  xml-soap/java/samples/bidbuy/shared/Address.java

  Index: Address.java
  ===================================================================
  package samples.bidbuy.shared;

  public class Address {

      // constructors

      public Address() {};

      public Address(String name, String address, String city, String state,
                     String zipCode)
      {
           this.name=name;
           this.address=address;
           this.city=city;
           this.state=state;
           this.zipCode=zipCode;
      }

      // properties

      private String name;
      public String getName() { return name; }
      public void setName(String value) { name=value; }

      private String address;
      public String getAddress() { return address; }
      public void setAddress(String value) { address=value; }

      private String city;
      public String getCity() { return city; }
      public void setCity(String value) { city=value; }

      private String state;
      public String getState() { return state; }
      public void setState(String value) { state=value; }

      private String zipCode;
      public String getZipCode() { return zipCode; }
      public void setZipCode(String value) { zipCode=value; }

      public String toString()
      {
        StringBuffer strBuf = new StringBuffer();

        strBuf.append(name + '\n');
        strBuf.append(address + '\n');
        strBuf.append(city + ", " + state + "  " + zipCode + '\n');

        return strBuf.toString();
      }
  }



  1.1
xml-soap/java/samples/bidbuy/shared/AddressSerializer.java

  Index: AddressSerializer.java
  ===================================================================
  package samples.bidbuy.shared;

  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;

  /**
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class AddressSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();

      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);

      sink.write(StringUtils.lineSeparator);

      Address addr = (Address)src;
      String name = addr.getName();
      String address = addr.getAddress();
      String city = addr.getCity();
      String state = addr.getState();
      String zipCode = addr.getZipCode();

      if (name != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      name,
                      "name",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (address != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      address,
                      "address",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (city != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      city,
                      "city",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (state != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      state,
                      "state",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (zipCode != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      zipCode,
                      "zipCode",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      sink.write("</" + context + '>');

      nsStack.popScope();
    }

    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
src,
                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException
    {
      Element addrElement = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(addrElement);
      Address addr = new Address();

      while (tempEl != null)
      {
        String tagName = tempEl.getTagName();

        if (tagName.equals("name"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          addr.setName((String)param.getValue());
        }
        else if (tagName.equals("address"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          addr.setAddress((String)param.getValue());
        }
        else if (tagName.equals("city"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          addr.setCity((String)param.getValue());
        }
        else if (tagName.equals("state"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          addr.setState((String)param.getValue());
        }
        else if (tagName.equals("zipCode"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          addr.setZipCode((String)param.getValue());
        }

        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }

      return new Bean(Address.class, addr);
    }
  }



  1.1                  xml-soap/java/samples/bidbuy/shared/LineItem.java

  Index: LineItem.java
  ===================================================================
  package samples.bidbuy.shared;

  import java.math.BigDecimal;

  public class LineItem {

      // constructors

      public LineItem() {};

      public LineItem(String name, int quantity, BigDecimal price) {
           this.name=name;
           this.quantity=quantity;
           this.price=price;
      }

      public LineItem(String name, int quantity, String price) {
           this.name=name;
           this.quantity=quantity;
           this.price=new BigDecimal(price);
      }

      // properties

      private String name;
      public String getName() { return name; }
      public void setName(String value) { name=value; }

      private int quantity;
      public int getQuantity() { return quantity; }
      public void setQuantity(int value) { quantity=value; }

      private BigDecimal price;
      public BigDecimal getPrice() { return price; }
      public void setPrice(BigDecimal value) { price=value; }

      public String toString()
      {
        return "Name=" + name + "  Quantity=" + quantity + "  Price=$" +
price;
      }
  }



  1.1
xml-soap/java/samples/bidbuy/shared/LineItemSerializer.java

  Index: LineItemSerializer.java
  ===================================================================
  package samples.bidbuy.shared;

  import java.io.*;
  import java.math.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;

  /**
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class LineItemSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();

      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);

      sink.write(StringUtils.lineSeparator);

      LineItem lineItem = (LineItem)src;
      String name = lineItem.getName();
      int quantity = lineItem.getQuantity();
      BigDecimal price = lineItem.getPrice();

      if (name != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      name,
                      "name",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      xjmr.marshall(inScopeEncStyle,
                    int.class,
                    new Integer(quantity),
                    "quantity",
                    sink,
                    nsStack,
                    ctx);

      sink.write(StringUtils.lineSeparator);

      if (price != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      BigDecimal.class,
                      price,
                      "price",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      sink.write("</" + context + '>');

      nsStack.popScope();
    }

    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
src,
                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException
    {
      Element lineItemElement = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(lineItemElement);
      LineItem lineItem = new LineItem();

      while (tempEl != null)
      {
        String tagName = tempEl.getTagName();

        if (tagName.equals("name"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          lineItem.setName((String)param.getValue());
        }
        else if (tagName.equals("quantity"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          lineItem.setQuantity(((Integer)param.getValue()).intValue());
        }
        else if (tagName.equals("price"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          lineItem.setPrice((BigDecimal)param.getValue());
        }

        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }

      return new Bean(LineItem.class, lineItem);
    }
  }



  1.1
xml-soap/java/samples/bidbuy/shared/PurchaseOrder.java

  Index: PurchaseOrder.java
  ===================================================================
  package samples.bidbuy.shared;

  import java.util.Date;

  public class PurchaseOrder {

      // constructors

      public PurchaseOrder() {};

      public PurchaseOrder(String id, Date createDate, Address shipTo,
                           Address billTo, LineItem[] items)
      {
           this.poID=id;
           this.createDate=createDate;
           this.shipTo=shipTo;
           this.billTo=billTo;
           this.items=items;
      }

      // properties

      private String poID;
      public String getPoID() { return poID; }
      public void setPoID(String value) { poID=value; }

      private Date createDate;
      public Date getCreateDate() { return createDate; }
      public void setCreateDate(Date value) { createDate=value; }

      private Address shipTo;
      public Address getShipTo() { return shipTo; }
      public void setShipTo(Address value) { shipTo=value; }

      private Address billTo;
      public Address getBillTo() { return billTo; }
      public void setBillTo(Address value) { billTo=value; }

      private LineItem[] items;
      public LineItem[] getItems() { return items; }
      public void setItems(LineItem[] value) { items=value; }

      public String toString()
      {
        StringBuffer strBuf = new StringBuffer();

        strBuf.append("Purchase Order ID: " + poID + '\n');
        strBuf.append("Creation Date: " + createDate + "\n\n");
        strBuf.append("Ship To\n=======\n" + shipTo + '\n');
        strBuf.append("Bill To\n=======\n" + billTo + '\n');
        strBuf.append("Items\n=====\n");

        if (items != null)
        {
          for (int i = 0; i < items.length; i++)
          {
            strBuf.append("Item #" + (i+1) + ": " + items[i] + '\n');
          }
        }

        return strBuf.toString();
      }
  }



  1.1                  xml-soap/java/samples/bidbuy/shared/PurchaseOrderSeri
alizer.java

  Index: PurchaseOrderSerializer.java
  ===================================================================
  package samples.bidbuy.shared;

  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import samples.bidbuy.shared.*;

  /**
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class PurchaseOrderSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();

      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);

      sink.write(StringUtils.lineSeparator);

      PurchaseOrder po = (PurchaseOrder)src;
      String poID = po.getPoID();
      Date createDate = po.getCreateDate();
      Address shipTo = po.getShipTo();
      Address billTo = po.getBillTo();
      LineItem[] items = po.getItems();

      if (poID != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      poID,
                      "poID",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (createDate != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      Date.class,
                      createDate,
                      "createDate",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (shipTo != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      Address.class,
                      shipTo,
                      "shipTo",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (billTo != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      Address.class,
                      billTo,
                      "billTo",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (items != null)
      {
        Parameter param = new Parameter("items",
                                        LineItem[].class,
                                        items,
                                        null);

        xjmr.marshall(inScopeEncStyle,
                      Parameter.class,
                      param,
                      null,
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      sink.write("</" + context + '>');

      nsStack.popScope();
    }

    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
src,
                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException
    {
      Element poElement = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(poElement);
      PurchaseOrder po = new PurchaseOrder();

      while (tempEl != null)
      {
        String tagName = tempEl.getTagName();

        if (tagName.equals("poID"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          po.setPoID((String)param.getValue());
        }
        else if (tagName.equals("createDate"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          po.setCreateDate((Date)param.getValue());
        }
        else if (tagName.equals("shipTo"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          po.setShipTo((Address)param.getValue());
        }
        else if (tagName.equals("billTo"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          po.setBillTo((Address)param.getValue());
        }
        else if (tagName.equals("items"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          po.setItems((LineItem[])param.getValue());
        }

        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }

      System.err.println("Returning: " + po);

      return new Bean(PurchaseOrder.class, po);
    }
  }



  1.1                  xml-soap/java/samples/bidbuy/shared/Service.java

  Index: Service.java
  ===================================================================
  package samples.bidbuy.shared;

  public class Service implements java.io.Serializable {
      private String ServiceName;
      private String ServiceUrl;
      private String ServiceType;
      private String ServiceWsdl;

      public String getServiceName() {
         return ServiceName;
      }

      public void setServiceName(String value) {
         ServiceName = value;
      }

      public String getServiceUrl() {
         return ServiceUrl;
      }

      public void setServiceUrl(String value) {
         ServiceUrl = value;
      }

      public String getServiceType() {
         return ServiceType;
      }

      public void setServiceType(String value) {
         ServiceType = value;
      }

      public String getServiceWsdl() {
         return ServiceWsdl;
      }

      public void setServiceWsdl(String value) {
         ServiceWsdl = value;
      }
  }



  1.1
xml-soap/java/samples/bidbuy/shared/ServiceSerializer.java

  Index: ServiceSerializer.java
  ===================================================================
  package samples.bidbuy.shared;

  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;

  /**
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class ServiceSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();

      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);

      sink.write(StringUtils.lineSeparator);

      Service svc = (Service)src;
      String serviceName = svc.getServiceName();
      String serviceUrl = svc.getServiceUrl();
      String serviceType = svc.getServiceType();
      String serviceWsdl = svc.getServiceWsdl();

      if (serviceName != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      serviceName,
                      "serviceName",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (serviceUrl != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      serviceUrl,
                      "serviceUrl",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (serviceType != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      serviceType,
                      "serviceType",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      if (serviceWsdl != null)
      {
        xjmr.marshall(inScopeEncStyle,
                      String.class,
                      serviceWsdl,
                      "serviceWsdl",
                      sink,
                      nsStack,
                      ctx);

        sink.write(StringUtils.lineSeparator);
      }

      sink.write("</" + context + '>');

      nsStack.popScope();
    }

    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node
src,
                           XMLJavaMappingRegistry xjmr, SOAPContext ctx)
      throws IllegalArgumentException
    {
      Element svcElement = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(svcElement);
      Service svc = new Service();

      while (tempEl != null)
      {
        String tagName = tempEl.getTagName();

        if (tagName.equals("serviceName"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          svc.setServiceName((String)param.getValue());
        }
        else if (tagName.equals("serviceUrl"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          svc.setServiceUrl((String)param.getValue());
        }
        else if (tagName.equals("serviceType"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          svc.setServiceType((String)param.getValue());
        }
        else if (tagName.equals("serviceWsdl"))
        {
          Bean bean = xjmr.unmarshall(inScopeEncStyle,
                                      RPCConstants.Q_ELEM_PARAMETER,
                                      tempEl,
                                      ctx);
          Parameter param = (Parameter)bean.value;

          svc.setServiceWsdl((String)param.getValue());
        }

        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }

      return new Bean(Service.class, svc);
    }
  }