axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/addrNoImplSEI AddressBook.wsdl AddressBookSOAPBindingImpl.java AddressBookTestCase.java DOMUtils.java Main.java
Date Tue, 21 May 2002 17:15:50 GMT
scheu       02/05/21 10:15:50

  Modified:    java/test/wsdl Wsdl2javaTestSuite.xml
  Added:       java/test/wsdl/addrNoImplSEI AddressBook.wsdl
                        AddressBookSOAPBindingImpl.java
                        AddressBookTestCase.java DOMUtils.java Main.java
  Removed:     java/test/addrNoImplSEI AddressBookSOAPBindingImpl.java
                        AddressBookTestCase.java deploy.wsdd
  Log:
  I moved the addrNoImplSEI testcase to the wsdl section of the testcase bucket.
  
  This testcase tests whether it is possible to have an implementation class
  that does not implement the web service interface (the SEI).
  
  Revision  Changes    Path
  1.99      +13 -0     xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml
  
  Index: Wsdl2javaTestSuite.xml
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/Wsdl2javaTestSuite.xml,v
  retrieving revision 1.98
  retrieving revision 1.99
  diff -u -r1.98 -r1.99
  --- Wsdl2javaTestSuite.xml	18 May 2002 14:08:31 -0000	1.98
  +++ Wsdl2javaTestSuite.xml	21 May 2002 17:15:50 -0000	1.99
  @@ -67,6 +67,19 @@
           <mapping namespace="urn:MultiRefTest2" package="test.wsdl.multiref"/>
       </wsdl2java>
   
  +    <!-- AddressBook Sample -->
  +    <wsdl2java url="test/wsdl/addrNoImplSEI/AddressBook.wsdl"
  +               output="build/work"
  +               deployscope="session"
  +               serverSide="yes"
  +               skeletonDeploy="no"
  +               noimports="no"
  +               verbose="no"
  +               typeMappingVersion="1.1"
  +               testcase="no">
  +        <mapping namespace="urn:AddrNoImplSEI" package="test.wsdl.addrNoImplSEI"/>
  +    </wsdl2java>
  +
       <!-- Operation style test (oneway, request/response, -->
       <!-- solicit/response, notification -->
       <wsdl2java url="test/wsdl/opStyles/opStyles.wsdl"
  
  
  
  1.1                  xml-axis/java/test/wsdl/addrNoImplSEI/AddressBook.wsdl
  
  Index: AddressBook.wsdl
  ===================================================================
  <?xml version="1.0" ?>
  
  <definitions name="urn:AddrNoImplSEI"
               targetNamespace="urn:AddrNoImplSEI"
               xmlns:tns="urn:AddrNoImplSEI"
               xmlns:typens="urn:AddrNoImplSEI"
               xmlns:xsd="http://www.w3.org/1999/XMLSchema"
               xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
               xmlns="http://schemas.xmlsoap.org/wsdl/">
  
    <!-- type defs -->
    <types>
      <xsd:schema targetNamespace="urn:AddrNoImplSEI"
                  xmlns:xsd="http://www.w3.org/1999/XMLSchema">
  
        <xsd:simpleType name="stateType">
          <xsd:restriction base="xsd:string">
              <xsd:enumeration value="TX"/>                      
              <xsd:enumeration value="IN"/>                    
              <xsd:enumeration value="OH"/>                    
          </xsd:restriction>
        </xsd:simpleType>
  
        <xsd:complexType name="phone">
          <xsd:all>
              <xsd:element name="areaCode" type="xsd:int"/>
              <xsd:element name="exchange" type="xsd:string"/>
              <xsd:element name="number" type="xsd:string"/>
          </xsd:all>
        </xsd:complexType>
  
        <xsd:complexType name="address">
          <xsd:all>
              <xsd:element name="streetNum" type="xsd:int"/>
              <xsd:element name="streetName" type="xsd:string"/>
              <xsd:element name="city" type="xsd:string"/>
              <xsd:element name="state" type="typens:stateType"/>
              <xsd:element name="zip" type="xsd:int"/>
              <xsd:element name="phoneNumber" type="typens:phone"/>
          </xsd:all>
        </xsd:complexType>
      </xsd:schema>
    </types>
  
    <!-- message declns -->
    <message name="AddEntryRequest">
      <part name="name" type="xsd:string"/>
      <part name="address" type="typens:address"/>
    </message>
  
    <message name="GetAddressFromNameRequest">
      <part name="name" type="xsd:string"/>
    </message>
  
    <message name="GetAddressFromNameResponse">
      <part name="address" type="typens:address"/>
    </message>
  
    <!-- port type declns -->
    <portType name="AddressBook">
      <operation name="addEntry">
        <input message="tns:AddEntryRequest"/>
      </operation>
      <operation name="getAddressFromName">
        <input message="tns:GetAddressFromNameRequest"/>
        <output message="tns:GetAddressFromNameResponse"/>
      </operation>
    </portType>
  
    <!-- binding declns -->
    <binding name="AddressBookSOAPBinding" type="tns:AddressBook">
      <soap:binding style="rpc"
                    transport="http://schemas.xmlsoap.org/soap/http"/>
      <operation name="addEntry">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="urn:AddrNoImplSEI"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <soap:body use="encoded"
                     namespace="urn:AddrNoImplSEI"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
      <operation name="getAddressFromName">
        <soap:operation soapAction=""/>
        <input>
          <soap:body use="encoded"
                     namespace="urn:AddrNoImplSEI"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </input>
        <output>
          <soap:body use="encoded"
                     namespace="urn:AddrNoImplSEI"
                     encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
        </output>
      </operation>
    </binding>
  
    <!-- service decln -->
    <service name="AddressBookService">
      <port name="AddressBookNoImplSEI" binding="tns:AddressBookSOAPBinding">
        <soap:address location="http://localhost:8080/axis/services/AddressBookNoImplSEI"/>
      </port>
    </service>
  
  </definitions>
  
  
  
  
  1.1                  xml-axis/java/test/wsdl/addrNoImplSEI/AddressBookSOAPBindingImpl.java
  
  Index: AddressBookSOAPBindingImpl.java
  ===================================================================
  /**
   * AddressBookSOAPBindingImpl.java
   *
   * This file was hand modified from the Emmitter generated code.
   */
  
  package test.wsdl.addrNoImplSEI;
  
  import java.util.Hashtable;
  import java.util.Map;
  
  // Don't implement the AddressBook interface
  public class AddressBookSOAPBindingImpl {
      private Map addresses = new Hashtable();
  
      public void addEntry(java.lang.String name, test.wsdl.addrNoImplSEI.Address address)
throws java.rmi.RemoteException {
          this.addresses.put(name, address);
      }
      public test.wsdl.addrNoImplSEI.Address getAddressFromName(java.lang.String name) throws
java.rmi.RemoteException {
          return (test.wsdl.addrNoImplSEI.Address) this.addresses.get(name);
      }
  }
  
  
  
  1.1                  xml-axis/java/test/wsdl/addrNoImplSEI/AddressBookTestCase.java
  
  Index: AddressBookTestCase.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Axis" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.wsdl.addrNoImplSEI;
  
  import junit.framework.TestCase;
  import org.apache.axis.AxisFault;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** Test the address book sample code.
   */
  public class AddressBookTestCase extends TestCase {
      static Log log =
              LogFactory.getLog(AddressBookTestCase.class.getName());
  
      public AddressBookTestCase(String name) {
          super(name);
      }
  
      public void doTest () throws Exception {
          String[] args = {};
          Main.main(args);
      }
  
      public void testAddressBookService () throws Exception {
          try {
              log.info("Testing address book sample.");
              doTest();
              log.info("Test complete.");
          }
          catch( Exception e ) {
              if ( e instanceof AxisFault ) ((AxisFault)e).dump();
              e.printStackTrace();
              throw new Exception("Fault returned from test: "+e);
          }
      }
  }
  
  
  
  
  
  1.1                  xml-axis/java/test/wsdl/addrNoImplSEI/DOMUtils.java
  
  Index: DOMUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2000, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.wsdl.addrNoImplSEI;
  
  import org.w3c.dom.Attr;
  import org.w3c.dom.CharacterData;
  import org.w3c.dom.Element;
  import org.w3c.dom.Node;
  import org.w3c.dom.NodeList;
  
  /**
   * @author Matthew J. Duftler
   * @author Sanjiva Weerawarana
   */
  public class DOMUtils {
      /**
       * The namespaceURI represented by the prefix <code>xmlns</code>.
       */
      private static String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/";
      
      /**
       * Returns the value of an attribute of an element. Returns null
       * if the attribute is not found (whereas Element.getAttribute
       * returns "" if an attrib is not found).
       *
       * @param el       Element whose attrib is looked for
       * @param attrName name of attribute to look for
       * @return the attribute value
       */
      static public String getAttribute (Element el, String attrName) {
          String sRet = null;
          Attr   attr = el.getAttributeNode(attrName);
          
          if (attr != null) {
              sRet = attr.getValue();
          }
          return sRet;
      }
      
      /**
       * Returns the value of an attribute of an element. Returns null
       * if the attribute is not found (whereas Element.getAttributeNS
       * returns "" if an attrib is not found).
       *
       * @param el       Element whose attrib is looked for
       * @param namespaceURI namespace URI of attribute to look for
       * @param localPart local part of attribute to look for
       * @return the attribute value
       */
      static public String getAttributeNS (Element el,
                                           String namespaceURI,
                                           String localPart) {
          String sRet = null;
          Attr   attr = el.getAttributeNodeNS (namespaceURI, localPart);
          
          if (attr != null) {
              sRet = attr.getValue ();
          }
          
          return sRet;
      }
      
      /**
       * Concat all the text and cdata node children of this elem and return
       * the resulting text.
       *
       * @param parentEl the element whose cdata/text node values are to
       *                 be combined.
       * @return the concatanated string.
       */
      static public String getChildCharacterData (Element parentEl) {
          if (parentEl == null) {
              return null;
          }
          Node          tempNode = parentEl.getFirstChild();
          StringBuffer  strBuf   = new StringBuffer();
          CharacterData charData;
          
          while (tempNode != null) {
              switch (tempNode.getNodeType()) {
                  case Node.TEXT_NODE :
                  case Node.CDATA_SECTION_NODE : charData = (CharacterData)tempNode;
                      strBuf.append(charData.getData());
                      break;
              }
              tempNode = tempNode.getNextSibling();
          }
          return strBuf.toString();
      }
      
      /**
       * Return the first child element of the given element. Null if no
       * children are found.
       *
       * @param elem Element whose child is to be returned
       * @return the first child element.
       */
      public static Element getFirstChildElement (Element elem) {
          for (Node n = elem.getFirstChild (); n != null; n = n.getNextSibling ()) {
              if (n.getNodeType () == Node.ELEMENT_NODE) {
                  return (Element) n;
              }
          }
          return null;
      }
      
      /**
       * Return the next sibling element of the given element. Null if no
       * more sibling elements are found.
       *
       * @param elem Element whose sibling element is to be returned
       * @return the next sibling element.
       */
      public static Element getNextSiblingElement (Element elem) {
          for (Node n = elem.getNextSibling (); n != null; n = n.getNextSibling ()) {
              if (n.getNodeType () == Node.ELEMENT_NODE) {
                  return (Element) n;
              }
          }
          return null;
      }
      
      /**
       * Return the first child element of the given element which has the
       * given attribute with the given value.
       *
       * @param elem      the element whose children are to be searched
       * @param attrName  the attrib that must be present
       * @param attrValue the desired value of the attribute
       *
       * @return the first matching child element.
       */
      public static Element findChildElementWithAttribute (Element elem,
                                                           String attrName,
                                                           String attrValue) {
          for (Node n = elem.getFirstChild (); n != null; n = n.getNextSibling ()) {
              if (n.getNodeType () == Node.ELEMENT_NODE) {
                  if (attrValue.equals (DOMUtils.getAttribute ((Element) n, attrName))) {
                      return (Element) n;
                  }
              }
          }
          return  null;
      }
      
      /**
       * Count number of children of a certain type of the given element.
       *
       * @param elem the element whose kids are to be counted
       *
       * @return the number of matching kids.
       */
      public static int countKids (Element elem, short nodeType) {
          int nkids = 0;
          for (Node n = elem.getFirstChild (); n != null; n = n.getNextSibling ()) {
              if (n.getNodeType () == nodeType) {
                  nkids++;
              }
          }
          return nkids;
      }
      
      /**
       * Given a prefix and a node, return the namespace URI that the prefix
       * has been associated with. This method is useful in resolving the
       * namespace URI of attribute values which are being interpreted as
       * QNames. If prefix is null, this method will return the default
       * namespace.
       *
       * @param context the starting node (looks up recursively from here)
       * @param prefix the prefix to find an xmlns:prefix=uri for
       *
       * @return the namespace URI or null if not found
       */
      public static String getNamespaceURIFromPrefix (Node context,
                                                      String prefix) {
          short nodeType = context.getNodeType ();
          Node tempNode = null;
          
          switch (nodeType)
          {
              case Node.ATTRIBUTE_NODE :
                  {
                      tempNode = ((Attr) context).getOwnerElement ();
                      break;
                  }
              case Node.ELEMENT_NODE :
                  {
                      tempNode = context;
                      break;
                  }
              default :
                  {
                      tempNode = context.getParentNode ();
                      break;
                  }
          }
          
          while (tempNode != null && tempNode.getNodeType () == Node.ELEMENT_NODE)
          {
              Element tempEl = (Element) tempNode;
              String namespaceURI = (prefix == null)
                  ? getAttribute (tempEl, "xmlns")
                  : getAttributeNS (tempEl, NS_URI_XMLNS, prefix);
              
              if (namespaceURI != null)
              {
                  return namespaceURI;
              }
              else
              {
                  tempNode = tempEl.getParentNode ();
              }
          }
          
          return null;
      }
      
      public static Element getElementByID(Element el, String id)
      {
          if (el == null)
              return null;
          String thisId = el.getAttribute("id");
          if (id.equals(thisId))
              return el;
          
          NodeList list = el.getChildNodes();
          for (int i = 0; i < list.getLength(); i++) {
              Node node = list.item(i);
              if (node instanceof Element) {
                  Element ret = getElementByID((Element)node, id);
                  if (ret != null)
                      return ret;
              }
          }
          
          return null;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/wsdl/addrNoImplSEI/Main.java
  
  Index: Main.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "SOAP" and "Apache Software Foundation" must
   *    not be used to endorse or promote products derived from this
   *    software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    nor may "Apache" appear in their name, without prior written
   *    permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation and was
   * originally based on software copyright (c) 2000, International
   * Business Machines, Inc., http://www.apache.org.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  package test.wsdl.addrNoImplSEI;
  
  import org.apache.axis.AxisFault;
  
  import org.apache.axis.utils.Options;
  
  import java.net.URL;
  
  
  
  /**
   * This class shows how to use the Call object's ability to
   * become session aware.
   *
   * @author Rob Jellinghaus (robj@unrealities.com)
   * @author Sanjiva Weerawarana <sanjiva@watson.ibm.com>
   */
  public class Main {
      static String name1;
      static Address addr1;
      static Phone phone1;
      
      static {
          name1 = "Purdue Boilermaker";
          addr1 = new Address();
          phone1 = new Phone();
          addr1.setStreetNum(1);
          addr1.setStreetName("University Drive");
          addr1.setCity("West Lafayette");
          addr1.setState(StateType.IN);
          addr1.setZip(47907);
          phone1.setAreaCode(765);
          phone1.setExchange("494");
          phone1.setNumber("4900");
          addr1.setPhoneNumber(phone1);
          
      }
      private static void printAddress (Address ad) {
          if (ad == null) {
              System.err.println ("\t[ADDRESS NOT FOUND!]");
              return;
          }
          System.err.println ("\t" + ad.getStreetNum() + " " +
                                  ad.getStreetName());
          System.err.println ("\t" + ad.getCity() + ", " + ad.getState() + " " +
                                  ad.getZip());
          Phone ph = ad.getPhoneNumber();
          System.err.println ("\tPhone: (" + ph.getAreaCode() + ") " +
                                  ph.getExchange() + "-" + ph.getNumber());
      }
      
      private static Object doit (AddressBook ab) throws Exception {
          System.err.println (">> Storing address for '" + name1 + "'");
          ab.addEntry (name1, addr1);
          System.err.println (">> Querying address for '" + name1 + "'");
          Address resp = ab.getAddressFromName (name1);
          System.err.println (">> Response is:");
          printAddress (resp);
          
          // if we are NOT maintaining session, resp must be == null.
          // If we ARE, resp must be != null.
          
          System.err.println (">> Querying address for '" + name1 + "' again");
          resp = ab.getAddressFromName (name1);
          System.err.println (">> Response is:");
          printAddress (resp);
          return resp;
      }
      
      public static void main (String[] args) throws Exception {
          try {
              Options opts = new Options(args);
  
              System.err.println ("Using proxy without session maintenance.");
              System.err.println ("(queries without session should say:  \"ADDRESS NOT FOUND!\")");
  
              AddressBookService abs = new AddressBookServiceLocator();
              opts.setDefaultURL( abs.getAddressBookNoImplSEIAddress() );
              URL serviceURL = new URL(opts.getURL());
  
              AddressBook ab1 = null;
              if (serviceURL == null) {
                  ab1 = abs.getAddressBookNoImplSEI();
              }
              else {
                  ab1 = abs.getAddressBookNoImplSEI(serviceURL);
              }
              Object ret = doit (ab1);
              if (ret != null) {
                  throw new Exception("non-session test expected null response, got "+ret);
              }
  
              System.err.println ("\n\nUsing proxy with session maintenance.");
              AddressBook ab2 = null;
              if (serviceURL == null) {
                  ab2 = abs.getAddressBookNoImplSEI();
              }
              else {
                  ab2 = abs.getAddressBookNoImplSEI(serviceURL);
              }
              ((AddressBookSOAPBindingStub) ab2).setMaintainSession (true);
              ret = doit (ab2);
              if (ret == null) {
                  throw new Exception("session test expected non-null response, got "+ret);
              }
          }
          catch (Exception e) {
              if (e instanceof AxisFault) {
                  System.err.println(((AxisFault) e).dumpToString());
              }
              else {
                  e.printStackTrace();
              }
          }
      }
  }
  
  
  

Mime
View raw message