You are viewing a plain text version of this content. The canonical link for it is here.
Posted to soap-dev@ws.apache.org by ru...@locus.apache.org on 2000/05/22 02:04:25 UTC

cvs commit: xml-soap/java/src/org/apache/soap/util/xml DOM2Writer.java DOMWriter.java Deserializer.java DomHash.java NSStack.java QName.java Serializer.java XMIDeserializer.java XMISerializer.java XMLJavaMappingRegistry.java XMLParserLiaison.java XPathUtils.java XercesParserLiaison.java

rubys       00/05/21 17:04:24

  Added:       .        LICENSE
               java     LICENSE ReleaseNotes.html build.xml
               java/samples/addressbook Address.java AddressBook.java
                        DeploymentDescriptor.xml GetAddress.java
                        PhoneNumber.java PutAddress.java README
               java/samples/calculator Calculator.java
                        DeploymentDescriptor.xml README
               java/samples/stockquote DeploymentDescriptor.xml
                        GetQuote.java GetQuoteSMTP.java README
                        StockQuoteService.java
               java/src/org/apache/soap AttributeHandler.java Body.java
                        Constants.java Envelope.java Fault.java Header.java
                        SOAPException.java Utils.java
               java/src/org/apache/soap/encoding SOAPMappingRegistry.java
               java/src/org/apache/soap/encoding/soapenc
                        ArraySerializer.java BeanSerializer.java
                        ParameterSerializer.java SoapEncUtils.java
               java/src/org/apache/soap/encoding/xmi
                        XMIParameterSerializer.java
               java/src/org/apache/soap/rpc Call.java Parameter.java
                        RPCConstants.java RPCMessage.java Response.java
               java/src/org/apache/soap/server DeploymentDescriptor.java
                        InvokeBSF.java SMTP2HTTPBridge.java
                        ServerConstants.java ServiceManager.java
                        ServiceManagerClient.java TypeMapping.java
                        TypeMappingSerializer.java blankpage.html
                        deploy.gif deploy.jsp header.html index.html
                        list.gif list.jsp rpcrouter.jsp showdetails.jsp
                        soapadmin.gif toc.html undeploy.gif undeploy.jsp
               java/src/org/apache/soap/transport SOAPTransport.java
               java/src/org/apache/soap/transport/http
                        SOAPHTTPConnection.java
               java/src/org/apache/soap/transport/smtp
                        POP3StatusListener.java SMTPConstants.java
                        SMTPUtils.java SOAPSMTPConnection.java
               java/src/org/apache/soap/util Bean.java DOMUtils.java
                        IOUtils.java IndentWriter.java JavaUtils.java
                        MethodUtils.java ObjInfo.java ObjectRegistry.java
                        ScriptSymbolTable.java StringUtils.java
               java/src/org/apache/soap/util/net HTTPUtils.java Relay.java
                        TcpTunnel.java TcpTunnelGui.java
               java/src/org/apache/soap/util/type TypeConvertor.java
                        TypeConvertorRegistry.java
               java/src/org/apache/soap/util/xml DOM2Writer.java
                        DOMWriter.java Deserializer.java DomHash.java
                        NSStack.java QName.java Serializer.java
                        XMIDeserializer.java XMISerializer.java
                        XMLJavaMappingRegistry.java XMLParserLiaison.java
                        XPathUtils.java XercesParserLiaison.java
  Log:
  initial load
  
  Revision  Changes    Path
  1.1                  xml-soap/LICENSE
  
  Index: LICENSE
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  
  1.1                  xml-soap/java/LICENSE
  
  Index: LICENSE
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 1999 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 "Xerces" 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) 1999, International
   * Business Machines, Inc., http://www.ibm.com.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  
  
  1.1                  xml-soap/java/ReleaseNotes.html
  
  Index: ReleaseNotes.html
  ===================================================================
  <html>
  
  <head>
  <meta http-equiv="Content-Type"
  content="text/html; charset=iso-8859-1">
  <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0">
  <title>xml-soap v1.2 Release Notes</title>
  </head>
  
  <body bgcolor="#FFFFFF">
  
  <h1 align="center">xml-soap v1.2 Release Notes</h1>
  
  <p align="center">May 19, 2000.</p>
  
  <h2 align="left">Table of Contents</h2>
  
  <ul>
      <li><p align="left"><a href="#Features of xml-soap"><font
          size="4"><strong>Features of xml-soap</strong></font></a></p>
      </li>
      <li><p align="left"><a
          href="#Using xml-soap for Remote Procedure Calls"><font
          size="4"><strong>Using xml-soap for Remote Procedure
          Calls</strong></font></a></p>
      </li>
      <li><p align="left"><a href="#RPC over SMTP"><font size="4"><strong>RPC
          over SMTP</strong></font></a></p>
      </li>
      <li><p align="left"><a
          href="#Using Apache Tomcat v3.1 for the Server-side"><font
          size="4"><strong>Using Apache Tomcat v3.1 for the
          Server-side</strong></font></a></p>
      </li>
      <li><p align="left"><a
          href="#Using IBM WebSphere v3.02 for the Server-side"><font
          size="4"><strong>Using IBM WebSphere v3.02 for the
          Server-side</strong></font></a></p>
      </li>
      <li><p align="left"><a
          href="#Running the Server Side Admin Tool to Manage Services"><font
          size="4"><strong>Running the Server Side Admin Tool to
          Manage Services</strong></font></a></p>
      </li>
      <li><p align="left"><a href="#Tool for Debugging SOAP"><font
          size="4"><strong>Tool for Debugging SOAP</strong></font></a></p>
      </li>
      <li><p align="left"><a href="#Implementation Restrictions"><font
          size="4"><strong>Implementation Restrictions</strong></font></a></p>
      </li>
      <li><p align="left"><a href="#Dependencies"><font size="4"><strong>Dependencies</strong></font></a></p>
      </li>
      <li><p align="left"><a href="#Building from Source"><font
          size="4"><strong>Building from Source</strong></font></a></p>
      </li>
      <li><p align="left"><a href="#Bugs"><font size="4"><strong>Bugs</strong></font></a></p>
      </li>
      <li><p align="left"><a href="#Authors"><font size="4"><strong>Authors</strong></font></a></p>
      </li>
  </ul>
  
  <h2><a name="Features of xml-soap">Features of xml-soap</a></h2>
  
  <ul>
      <li>Supports most of the SOAP v1.1 specification</li>
      <li>Provides server-side infrastructure for deploying,
          managing and running SOAP enabled services</li>
      <li>Provides client-side API for invoking SOAP services</li>
      <li>Supports two encoding styles: SOAP v1.1 Encoding and XMI
          with others to come</li>
      <li>XMI encoding (available when using Java 1.2.2) supports
          automatic marshalling and unmarshalling of arbitrary
          objects</li>
      <li>SOAP encoding: built-in support is provided for
          encoding/decoding primitive types, Strings, arbitrary
          JavaBeans (using reflection) and 1-dimensional arrays of
          these types. For other types user can hand-write
          encoder/decoder and register with xml-soap runtime.</li>
      <li>Supports messaging and RPC over two transports: HTTP and
          SMTP</li>
  </ul>
  
  <h2><a name="Using xml-soap for Remote Procedure Calls">Using
  xml-soap for Remote Procedure Calls</a></h2>
  
  <p>The org.apache.soap.rpc package supports performing RPC over
  SOAP. The xml-soap model is as follows: </p>
  
  <p>The URI of the method call element is used as the object ID on
  the remote side. The client side API has a &quot;Call&quot;
  object (org.apache.soap.rpc.Call) that is filled in with the method
  name, object ID and parameters. The marshalling/unmarshalling of
  Java datatypes to/from XML is supported by a type mapping
  registry (see org.apache.soap.encoding.SOAPMappingRegistry), and
  serialization (org.apache.util.xml.Serializer) and deserialization
  (org.apache.util.xml.Deserialization) interfaces that marshallers and
  unmarshallers, respectively, must implement. The built-in
  encoders/decoders are simply implementations of these interfaces
  that are preregistered in the SOAPMappingRegistry. </p>
  
  <p>Once a Call object is set up, its invoke (URL, String) method
  may be called to call the method using the URL as the SOAP
  endpoint to deliver to and the 2nd argument being the value of
  the SOAPAction header. This method returns a Response object
  (org.apache.soap.rpc.Response) which contains the actual response
  (if any) or the fault if a fault was generated.</p>
  
  <p>If the RPC is carried over HTTP, the server-side RPC router
  (rpcrouter.jsp in the webapp directory) receives the POST-ed
  envelope, unmarshalls it and then builds a Call object. Then, the
  target object is located by looking up the object ID in the
  ServiceManager's (org.apache.soap.server.ServiceManager), the method
  name is verified and then the invoke (Object) method is called to
  call the method on the target object. The return value is a
  Result (org.apache.soap.rpc.Result) object which is then marshalled
  and sent back as the HTTP response. </p>
  
  <p>If the RPC is carried over SMTP, then it goes to a mailbox and
  sits there waiting to be acted upon. We provide a POP3 to HTTP to
  SMTP bridge to receive these mail messages, post the content to
  an HTTP SOAP endpoint, get the result and forward the result by
  mail (SMTP) to the original sender. The receiving side will poll
  the POP3 server, receive the message, extract the content,
  unmarshall and return the Response to the original caller.</p>
  
  <h2><a name="RPC over SMTP">RPC over SMTP</a></h2>
  
  <p>To do RPC over SMTP in xml-soap a certain amount of email
  infrastructure needs to be available. Namely, you need an SMTP
  server, a POP3 server and an email address that you can use to be
  the equivalent of the server-side HTTP router. That is, all SOAP
  RPC calls are sent to a specific address which then processes the
  request somehow and send the result to the sender. To avoid
  duplicating the server-side infrastructure, we have implemented
  the SMTP server-side as a bridge that receives mail sent to the
  SOAP router email address via POP3, posts the SOAP envelope to an
  existing HTTP SOAP infrastructure and sends the response back to
  the sender of the email request via SMTP.</p>
  
  <p>On the client side, the application sends the SOAP request via
  SMTP to the SOAP router email address indicating the address that
  the response should be sent to. Then, it starts polling a POP3
  server to see whether the response has arrived. When it does, the
  envelope is parsed and the respose is extracted. We are using a <a
  href="http://www.alphaworks.ibm.com/aw.nsf/frame?ReadForm&amp;/ab.nsf/techmain/AD8820E9114E5B4488256723000AC87A">POP3
  bean from alphaWorks</a> for the POP3 stuff and that bean does
  not support selective downloading of email. As a result, the
  current implementation relies on the &quot;next message&quot;
  arriving to the client's reply address to be the message
  containing the response to the request. The implication is that
  current implementation does not allow you to make multiple RPC
  calls using the same reply address at the same time.</p>
  
  <p><strong>NOTE</strong>: We <em>strongly</em> recommend against
  using your own email address for testing RPC over SMTP. There are
  many free POP3 email providers on the Web (such as <a
  href="http://www.mailandnews.com">www.mailandnews.com</a>, for
  example) if you are unable to set up multiple POP3 accounts
  yourself.</p>
  
  <h2><a name="Using Apache Tomcat v3.1 for the Server-side">Using
  Apache Tomcat v3.1 for the Server-side</a></h2>
  
  <p><strong>IMPORTANT</strong>: Tomcat comes with an XML parser
  (lib/xml.jar) which has the DOM level 1 interfaces. Even if you
  put Xerces 1.0.3's xerces.jar in your classpath, the wrong
  interfaces are found by any Java code running in Tomcat because
  the shell script / batch file that runs Tomcat puts the user's
  classpath at the end. So, you must edit tomcat.sh or tomcat.bin
  in the bin/ directory and put xerces.jar at the BEGINING of the
  classpath the script builds. </p>
  
  <p>If you run startup.bat, then line 38 of tomcat.bat should look
  like this:</p>
  
  <blockquote>
      <pre>set CLASSPATH=path-to-xerces\xerces.jar;%CLASSPATH%;%cp%</pre>
  </blockquote>
  
  <p>If you run startup.sh, add the following after line 111:</p>
  
  <blockquote>
      <pre>CLASSPATH=path-to-xerces/xerces.jar:${CLASSPATH}</pre>
  </blockquote>
  
  <p>The easiest way to set up for Tomcat is to add a
  &lt;Context&gt; to conf/server.xml:</p>
  
  <pre>&lt;Context path=&quot;/xml-soap&quot; docBase=&quot;path-to-xml-soap/xml-soap-1.2/webapp&quot; 
           debug=&quot;1&quot; reloadable=&quot;true&quot; &gt;
  &lt;/Context&gt;</pre>
  
  <p>Now, make sure you have the jar files from the lib directory
  of this distribution on your classpath and startup tomcat. Also
  you will want to have on the classpath any of your code that you
  want to deploy as services.</p>
  
  <p>You should be able to deploy services by pointing a browser to</p>
  
  <blockquote>
      <pre><a href="http://hostname:port/xml-soap">http://hostname:port/xml-soap</a></pre>
  </blockquote>
  
  <p>where hostname is the host on which Tomcat is running and port
  is the port. See the next section for details on the
  aministration tool. The SOAP end-point for invoking services on
  this server is:</p>
  
  <blockquote>
      <pre><a href="http://hostname:port/xml-soap">http://hostname:port/xml-soap/rpcrouter.jsp</a></pre>
  </blockquote>
  
  <p>Happy SOAP-ing!</p>
  
  <h2><a name="Using IBM WebSphere v3.02 for the Server-side">Using
  IBM WebSphere v3.02 for the Server-Side</a></h2>
  
  <p><strong>Thanks to Paul Fremantle and Paul Tamminga of IBM
  Software Group for their assistance with this!</strong></p>
  
  <p><strong>IMPORTANT</strong>: We use Apache Tomcat 3.1 in our
  development. Tomcat comes with an XML parser (lib/xml.jar) which
  has the DOM level 1 interfaces. Even if you put Xerces 1.0.3's
  xerces.jar in your classpath, the wrong interfaces are found by
  any Java code running in Tomcat because the shell script / batch
  file that runs Tomcat puts the user's classpath at the end. So,
  you must edit tomcat.sh or tomcat.bin in the bin/ directory and
  put xerces.jar at the BEGINING of the classpath the script
  builds. </p>
  
  <p>If you run startup.bat, then line 38 of tomcat.bat should look
  like this:</p>
  
  <blockquote>
      <pre>set CLASSPATH=path-to-xerces\xerces.jar;%CLASSPATH%;%cp%</pre>
  </blockquote>
  
  <p>If you run startup.sh, add the following after line 111:</p>
  
  <blockquote>
      <pre>CLASSPATH=path-to-xerces/xerces.jar:${CLASSPATH}</pre>
  </blockquote>
  
  <p>The easiest way to set up for Tomcat is to add a
  &lt;Context&gt; to conf/server.xml:</p>
  
  <pre>&lt;Context path=&quot;/xml-soap&quot; docBase=&quot;path-to-xml-soap/xml-soap-1.2/webapp&quot; 
           debug=&quot;1&quot; reloadable=&quot;true&quot; &gt;
  &lt;/Context&gt;</pre>
  
  <p>Now, make sure you have the jar files from the lib directory
  of this distribution on your classpath and startup tomcat. Also
  you will want to have on the classpath any of your code that you
  want to deploy as services.</p>
  
  <p>You should be able to deploy services by pointing a browser to</p>
  
  <blockquote>
      <pre><a href="http://hostname:port/xml-soap">http://hostname:port/xml-soap</a></pre>
  </blockquote>
  
  <p>where hostname is the host on which Tomcat is running and port
  is the port. See the next section for details on the
  aministration tool. The SOAP end-point for invoking services on
  this server is:</p>
  
  <blockquote>
      <pre><a href="http://hostname:port/xml-soap">http://hostname:port/xml-soap/rpcrouter.jsp</a></pre>
  </blockquote>
  
  <p>Happy SOAP-ing!</p>
  
  <h2><a
  name="Running the Server Side Admin Tool to Manage Services">Running
  the Server Side Admin Tool to Manage Services</a></h2>
  
  <p>With the xml-soap Administration Tools it is possible to use a
  Web browser to deploy and un-deploy services and to review the
  list and the definitions of the services deployed on a given SOAP
  server. </p>
  
  <p>Point your browse to <a href="http://hostname:port/xml-soap">http://hostname:port/xml-soap</a>
  (see above) and you will get the &quot;xml-soap Admin&quot;
  screen with three options:</p>
  
  <ul>
      <li><b>Deploy </b>to deploy a new service. </li>
      <li><b>Un-deploy </b>to remove a deployed service. </li>
      <li><b>List to </b>shows the list of services currently
          deployed in the server.</li>
  </ul>
  
  <p>The usage of these functions is immediate once one understands
  the nature of the information required for deploying a service.
  In the next section we describe this information.<b> </b></p>
  
  <p><b>Service Deployment Information</b></p>
  
  <p>We review here the information that defines a deployed
  service. This information must be provided when using the Deploy
  function, and can be browsed using the List function. We refer to
  this information as &quot;properties&quot; of the service. </p>
  
  <ul>
      <li><b>ID.</b> An URN uniquely identifies the service to
          clients. It must be unique among the deployed services,
          and be encoded as a URI. We commonly use the format:
          urn:UniqueServiceID . It corresponds to the target object
          ID, in the terminology of the SOAP specification. </li>
      <li><b>Scope. </b>Defines the lifetime of the object serving
          the invocation request. This corresponds scope attribute
          of the &lt;jsp:useBean&gt; tag in the JavaServer Pages.
          It may thus have the following possible values: <ul>
              <li><b>page:</b> the object is available until the
                  target JSP page (in this case the rpcrouter.jsp)
                  sends a response back or the request is forwarded
                  to another page (if you are using the standard
                  deployment mechanism this is unlikely to happen).
              </li>
              <li><b>request: </b>the object is available for the
                  complete duration of the request, regardless of
                  forwarding. </li>
              <li><b>session: </b>the object is available for the
                  complete duration of the session. </li>
              <li><b>application: </b>any page within the
                  application may access the object. In particular,
                  successive service invocations belonging to
                  different sessions will share the same instance
                  of the object. It is important to observe that
                  the value of this attribute can have important
                  security implications. The page and request
                  scopes assure the isolation of successive calls.
                  On the other extreme, application scope implies
                  that all service objects are shared among
                  different users of the SOAP server. A document
                  describing usage scenarios for different scopes
                  will be forthcoming. </li>
          </ul>
      </li>
      <li><b>Use static class. </b>If set to<b> </b>&quot;Yes&quot;
          the class method that is made available is a static
          method, and thus no object will be instantiated. When
          static invocation is used, the &quot;scope&quot; property
          is not applicable. </li>
      <li><b>Method list. </b>Defines the names of the method that
          can be invoked on this service object. </li>
      <li><b>Provider class.</b> Fully specified class name of the
          target object servicing the request. </li>
      <li><b>Type mappings. </b>In order to control the
          serialization and deserialization of specific Java types
          to and from XML in a particular encoding style, it may be
          necessary to provide serialization and deserialization
          classes that know how to perform the correct conversions
          for those types. The xml-soap server already includes
          serialization classes for most basic types in the SOAP
          encoding style, as well as a Bean encoding class that can
          provide a generic serialization of a bean in terms of its
          properties. It also includes XMI serializer/deserializer
          classes to support the XMI encoding style. Since
          different types may require additional support for
          correct serialization, the xml-soap maintains a registry
          of Serializers and Deserializers. The registry is
          accessible to service administrators through the xml-soap
          administration tool, as well as through a program API. In
          order to register a (de)serializer class, the class must
          implement the Serializer or Deserializer interfaces, see
          JavaDocs for org.apache.util.xml.Serializer and
          org.apache.util.xml.Deserializer .</li>
  </ul>
  
  <h2><a name="Tool for Debugging SOAP">Tool for Debugging SOAP</a></h2>
  
  <p>xml-soap also includes a TCP tunnel / monitor tool that we
  developed to help debug SOAP and other TCP protocols. The class
  org.apache.util.net.TcpTunnelGui can be used to open a port on the
  current machine which basically acts as a tunnel to a remote host
  / port combination. When a connection is made to the port, the
  tunnel in turn makes a connection to the remote host / port
  combination and uses two windows to show the data going from each
  side. Thus, the client wishing to make a connection to a remote
  host/port can be told to connect to the local host / port and as
  a result you can see the data that's flowing between the two.
  This provides a very useful debugging tool. Check it out!</p>
  
  <h2><a name="Implementation Restrictions">Implementation
  Restrictions</a></h2>
  
  <p>The following features of the SOAP v1.1 specification are <strong>not</strong>
  currently supported:</p>
  
  <ul>
      <li>encodingStyle attribute must have only one encoding style
          given (see section 4.1.1 of the spec)</li>
      <li>mustUnderstand attribute</li>
      <li>root attribute</li>
      <li>actor attribute and SOAP intermediaries</li>
      <li>ID/href links and multi-ref accessors</li>
      <li>all but the following XML Schema simple types: string,
          boolean, double, float, long, int, short, byte</li>
  </ul>
  
  <h2><a name="Dependencies">Dependencies</a></h2>
  
  <ul>
      <li>XMI encoding requires use of Java 1.2.2 and XML4J 2.0.15.
          The rest of xml-soap requires Apache Xerces 1.0.3. Your
          classpath must have xerces.jar first and then xml4j.jar
          next <strong>in that order</strong>. </li>
      <li>We have been running the server-side code under Apache
          Tomcat v3.1. However, we require a DOM level 2 and we
          used Apache Xerces 1.0.3. Given that Tomcat ships with
          its own XML parser which supports DOM level 1, you have
          to do a bit of work to get Tomcat to work right.</li>
  </ul>
  
  <h2><a name="Building from Source">Building from Source</a></h2>
  
  <p>You should be able to build everything from the sources in the
  src directory. The makefiles use a variable set in
  lib/make.include called PATHSEP to indicate whether to use
  &quot;;&quot; (for Win32) or &quot;:&quot; (for Unices). Saying
  make in the src directory should recurse down and build all
  (assuming your classpath is right).</p>
  
  <h2><a name="Bugs">Bugs</a></h2>
  
  <p>None that we know of right now ..</p>
  
  <p>While not strictly a bug, the docs are pretty lacking yet. We
  are working on much improved documentation (both external and
  within the source)!</p>
  
  <h2><a name="Authors">Authors</a></h2>
  
  <blockquote>
      <p>Matthew J. Duftler, <a href="mailto:duftler@us.ibm.com">duftler@us.ibm.com</a>,<br>
      Sanjiva Weerawarana, <a href="mailto:sanjiva@watson.ibm.com">sanjiva@watson.ibm.com</a>,<br>
      Francisco Curbera, <a href="mailto:curbera@us.ibm.com">curbera@us.ibm.com</a><br>
      <br>
      Component Systems Group<br>
      IBM TJ Watson Research Center<br>
      Hawthorne, NY 10532. <br>
      </p>
  </blockquote>
  </body>
  </html>
  
  
  
  1.1                  xml-soap/java/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <!-- ===================================================================
  
     Build file for Soap
  
  Notes:
     This is a build file for use with the Jakarta Ant build tool.
  
  Prerequisites:
  
     jakarta-ant from http://jakarta.apache.org
     xml-xerces from http://xml.apache.org
  
  Optional additions:
  
     http://www.alphaworks.ibm.com/tech/xmitoolkit
     http://oss.software.ibm.com/developerworks/opensource/pop3/index.html
     http://oss.software.ibm.com/developerworks/opensource/smtp/index.html
     
  Build Instructions:
     To build, run
  
       java org.apache.tools.ant.Main <target>
  
     on the directory where this file is located with the target you want.
  
  Most useful targets:
  
   - compile  -> creates the "soap.jar" package in "./build/lib"
   - javadocs -> creates the javadocs in "./build/javadocs"
   - dist     -> creates the complete distribution
  
  Authors:
    Sam Ruby <ru...@us.ibm.com>
  
  
  Copyright:
    Copyright (c) 2000 Apache Software Foundation.
  
     $Id: build.xml,v 1.1 2000/05/22 00:03:45 rubys Exp $
  
  ==================================================================== -->
  
  <project default="compile" basedir=".">
  
    <target name="init">
      <property name="name" value="soap"/>
      <property name="Name" value="Soap"/>
      <property name="version" value="1.2"/>
      <property name="year" value="2000"/>
  
      <property name="build.compiler" value="classic"/>
      <property name="debug" value="off"/>
  
      <property name="src.dir" value="./src"/>
      <property name="docs.dir" value="./docs"/>
      <property name="samples.dir" value="./samples"/>
  
      <property name="packages" value="org.*"/>
  
      <property name="build.dir" value="./build"/>
      <property name="build.dest" value="./build/classes"/>
      <property name="build.lib" value="./build/lib"/>
      <property name="build.docs" value="./build/docs/html"/>
      <property name="build.samples" value="./build/samples"/>
      <property name="build.javadocs" value="./build/javadocs"/>
  
      <property name="dist.dir" value="./dist"/>
    </target>
  
    <!-- =================================================================== -->
    <!-- Prepares the build directory                                        -->
    <!-- =================================================================== -->
    <target name="prepare" depends="init">
      <mkdir dir="${build.dir}"/>
      <available property="bsf.present" classname="com.ibm.bsf.BSFManager" />
      <available property="xmi.present" classname="com.ibm.xmi.job.Job" />
      <available property="pop3.present" 
        classname="com.ibm.network.mail.pop3.event.StatusListener" />
      <available property="smtp.present" 
        classname="com.ibm.network.mail.smtp.protocol.CoreProtocolBean" />
    </target>
  
    <!-- =================================================================== -->
    <!-- Compiles the source directory                                       -->
    <!-- =================================================================== -->
    <target name="compile" depends="prepare">
      <mkdir dir="${build.dest}"/>
      <javac srcdir="${src.dir}" destdir="${build.dest}" debug="${debug}">
        <exclude name="**/InvokeBSF.java" unless="bsf.present" />
        <exclude name="**/*SMTP*.java" unless="smtp.present" />
        <exclude name="**/*SMTP*.java" unless="pop3.present" />
        <exclude name="**/POP*.java" unless="smtp.present" />
        <exclude name="**/POP*.java" unless="pop3.present" />
        <exclude name="**/XMI*.java" unless="xmi.present" />
      </javac>
      <mkdir dir="${build.lib}"/>
      <jar jarfile="${build.lib}/${name}.jar" basedir="${build.dest}" />
    </target>
  
    <!-- =================================================================== -->
    <!-- Compiles the samples                                                -->
    <!-- =================================================================== -->
    <target name="samples" depends="compile">
      <mkdir dir="${build.samples}"/>
      <javac srcdir="${samples.dir}" destdir="${build.samples}" 
             classpath="${build.dir}/${name}.jar" debug="${debug}"/>
      <copydir src="${samples.dir}" dest="${build.samples}" />
    </target>
  
    <!-- =================================================================== -->
    <!-- Creates the API documentation                                       -->
    <!-- =================================================================== -->
    <target name="javadocs" depends="prepare">
      <mkdir dir="${build.javadocs}"/>
      <javadoc2 packagenames="${packages}"
                sourcepath="${src.dir}"
                destdir="${build.javadocs}"
                author="true"
                version="true"
                use="true"
                windowtitle="${Name} API"
                doctitle="${Name}"
                bottom="Copyright &#169; ${year} Apache XML Project. All Rights Reserved."
      />
    </target>
  
    <!-- =================================================================== -->
    <!-- Creates the distribution                                            -->
    <!-- =================================================================== -->
    <target name="dist" depends="compile, javadocs, samples">
      <mkdir dir="${dist.dir}"/>
      <mkdir dir="${dist.dir}/docs"/>
      <mkdir dir="${dist.dir}/docs/apiDocs"/>
      <mkdir dir="${dist.dir}/lib"/>
      <mkdir dir="${dist.dir}/samples"/>
      <mkdir dir="${dist.dir}/webapps"/>
  
      <copydir src="${build.javadocs}" dest="${dist.dir}/docs/apiDocs"/>
      <copydir src="${build.lib}" dest="${dist.dir}/lib"/>
      <copydir src="${build.samples}" dest="${dist.dir}/samples"/>
      <copydir src="${src.dir}/org/apache/soap/server" 
               dest="${dist.dir}/webapps">
        <include name="*.html" />
        <include name="*.jsp" />
        <include name="*.gif" />
      </copydir>
  
      <copyfile src="LICENSE" dest="${dist.dir}/LICENSE"/>
      <copyfile src="README" dest="${dist.dir}/README"/>
      <copyfile src="ReleaseNotes.html" dest="${dist.dir}/ReleaseNotes.html"/>
    </target>
  
    <!-- =================================================================== -->
    <!-- Cleans everything                                                   -->
    <!-- =================================================================== -->
    <target name="clean" depends="init">
      <deltree dir="${build.dir}"/>
      <deltree dir="${dist.dir}"/>
    </target>
  
  </project>
  
  
  
  1.1                  xml-soap/java/samples/addressbook/Address.java
  
  Index: Address.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.addressbook;
  
  /**
   * See \demos\addressbook\readme for info.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class Address
  {
    private int         streetNum;
    private String      streetName;
    private String      city;
    private String      state;
    private int         zip;
    private PhoneNumber phoneNumber;
  
    public Address()
    {
    }
  
    public Address(int streetNum, String streetName, String city, String state,
                   int zip, PhoneNumber phoneNumber)
    {
      this.streetNum = streetNum;
      this.streetName = streetName;
      this.city = city;
      this.state = state;
      this.zip = zip;
      this.phoneNumber = phoneNumber;
    }
  
    public void setStreetNum(int streetNum)
    {
      this.streetNum = streetNum;
    }
  
    public int getStreetNum()
    {
      return streetNum;
    }
  
    public void setStreetName(String streetName)
    {
      this.streetName = streetName;
    }
  
    public String getStreetName()
    {
      return streetName;
    }
  
    public void setCity(String city)
    {
      this.city = city;
    }
  
    public String getCity()
    {
      return city;
    }
  
    public void setState(String state)
    {
      this.state = state;
    }
  
    public String getState()
    {
      return state;
    }
  
    public void setZip(int zip)
    {
      this.zip = zip;
    }
  
    public int getZip()
    {
      return zip;
    }
  
    public void setPhoneNumber(PhoneNumber phoneNumber)
    {
      this.phoneNumber = phoneNumber;
    }
  
    public PhoneNumber getPhoneNumber()
    {
      return phoneNumber;
    }
  
    public String toString()
    {
      return streetNum + " " + streetName + "\n" +
             city + ", " + state + " " + zip + "\n" +
             phoneNumber;
    }
  }
  
  
  1.1                  xml-soap/java/samples/addressbook/AddressBook.java
  
  Index: AddressBook.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.addressbook;
  
  import java.util.*;
  
  /**
   * See \demos\addressbook\readme for info.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class AddressBook
  {
    private Hashtable name2AddressTable = new Hashtable();
  
    public AddressBook()
    {
      addEntry("John B. Good",
               new Address(123, "Main Street", "Anytown", "NY", 12345,
                           new PhoneNumber(123, "456", "7890")));
    }
  
    public void addEntry(String name, Address address)
    {
      name2AddressTable.put(name, address);
    }
  
    public Address getAddressFromName(String name)
      throws IllegalArgumentException
    {
      if (name == null)
      {
        throw new IllegalArgumentException("The name argument must not be " +
                                           "null.");
      }
  
      return (Address)name2AddressTable.get(name);
    }
  }
  
  
  1.1                  xml-soap/java/samples/addressbook/DeploymentDescriptor.xml
  
  Index: DeploymentDescriptor.xml
  ===================================================================
  <isd:service xmlns:isd="http://www.ibm.com/namespaces/ibm-soap/deployment"
               id="urn:AddressFetcher">
    <isd:provider type="java"
                  scope="Application"
                  methods="getAddressFromName addEntry">
      <isd:java class="demos.addressbook.AddressBook" static="false"/>
    </isd:provider>
    <isd:mappings>
      <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               xmlns:x="urn:ibm-soap-address-demo" qname="x:address"
               javaType="demos.addressbook.Address"
               java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
               xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
      <isd:map encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
               xmlns:x="urn:ibm-soap-address-demo" qname="x:phone"
               javaType="demos.addressbook.PhoneNumber"
               java2XMLClassName="org.apache.soap.encoding.soapenc.BeanSerializer"
               xml2JavaClassName="org.apache.soap.encoding.soapenc.BeanSerializer"/>
    </isd:mappings>    
  </isd:service>
  
  
  
  1.1                  xml-soap/java/samples/addressbook/GetAddress.java
  
  Index: GetAddress.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.addressbook;
  
  import java.io.*;
  import java.util.*;
  import java.net.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  
  /**
   * See \demos\addressbook\readme for info.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class GetAddress
  {
    public static void main(String[] args) throws Exception 
    {
      if (args.length != 2
          && (args.length != 3 || !args[0].startsWith("-")))
      {
        System.err.println("Usage:");
        System.err.println("  java " + GetAddress.class.getName() +
                           " [-encodingStyleURI] SOAP-router-URL nameToLookup");
        System.exit (1);
      }
  
      // Process the arguments.
      int offset = 3 - args.length;
      String encodingStyleURI = args.length == 3
                                ? args[0].substring(1)
                                : Constants.NS_URI_SOAP_ENC;
      URL url = new URL(args[1 - offset]);
      String nameToLookup = args[2 - offset];
      SOAPMappingRegistry smr = new SOAPMappingRegistry();
      BeanSerializer beanSer = new BeanSerializer();
  
      // Map the types.
      smr.mapTypes(Constants.NS_URI_SOAP_ENC,
                   new QName("urn:ibm-soap-address-demo", "address"),
                   Address.class, beanSer, beanSer);
      smr.mapTypes(Constants.NS_URI_SOAP_ENC,
                   new QName("urn:ibm-soap-address-demo", "phone"),
                   PhoneNumber.class, beanSer, beanSer);
  
      // Build the call.
      Call call = new Call();
  
      call.setSOAPMappingRegistry(smr);
      call.setTargetObjectURI("urn:AddressFetcher");
      call.setMethodName("getAddressFromName");
      call.setEncodingStyleURI(encodingStyleURI);
  
      Vector params = new Vector();
  
      params.addElement(new Parameter("nameToLookup", String.class,
                                      nameToLookup, null));
      call.setParams(params);
  
      // Invoke the call.
      Response resp;
  
      try
      {
        resp = call.invoke(url, "");
      }
      catch (SOAPException e)
      {
        System.err.println("Caught SOAPException (" +
                           e.getFaultCode() + "): " +
                           e.getMessage());
        return;
      }
  
      // Check the response.
      if (!resp.generatedFault())
      {
        Parameter ret = resp.getReturnValue();
        Object value = ret.getValue();
  
        System.out.println(value != null ? "\n" + value : "I don't know.");
      }
      else
      {
        Fault fault = resp.getFault();
  
        System.err.println("Generated fault: ");
        System.out.println ("  Fault Code   = " + fault.getFaultCode());  
        System.out.println ("  Fault String = " + fault.getFaultString());
      }
    }
  }
  
  
  1.1                  xml-soap/java/samples/addressbook/PhoneNumber.java
  
  Index: PhoneNumber.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.addressbook;
  
  /**
   * See \demos\addressbook\readme for info.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class PhoneNumber
  {
    private int    areaCode;
    private String exchange;
    private String number;
  
    public PhoneNumber()
    {
    }
  
    public PhoneNumber(int areaCode, String exchange, String number)
    {
      this.areaCode = areaCode;
      this.exchange = exchange;
      this.number   = number;
    }
  
    public void setAreaCode(int areaCode)
    {
      this.areaCode = areaCode;
    }
  
    public int getAreaCode()
    {
      return areaCode;
    }
  
    public void setExchange(String exchange)
    {
      this.exchange = exchange;
    }
  
    public String getExchange()
    {
      return exchange;
    }
  
    public void setNumber(String number)
    {
      this.number = number;
    }
  
    public String getNumber()
    {
      return number;
    }
  
    public String toString()
    {
      return "(" + areaCode + ") " + exchange + "-" + number;
    }
  }
  
  
  1.1                  xml-soap/java/samples/addressbook/PutAddress.java
  
  Index: PutAddress.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.addressbook;
  
  import java.io.*;
  import java.util.*;
  import java.net.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.rpc.*;
  
  /**
   * See \demos\addressbook\readme for info.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class PutAddress
  {
    public static void main(String[] args) throws Exception 
    {
      if (args.length != 10
          && (args.length != 11 || !args[0].startsWith("-")))
      {
        System.err.println("Usage:");
        System.err.println("  java " + PutAddress.class.getName() +
                           " [-encodingStyleURI] SOAP-router-URL name " +
                           "streetNum streetName city state zip areaCode " +
                           "exchange number");
        System.exit (1);
      }
  
      // Process the arguments.
      int offset = 11 - args.length;
      String encodingStyleURI = args.length == 11
                                ? args[0].substring(1)
                                : Constants.NS_URI_SOAP_ENC;
      URL url = new URL(args[1 - offset]);
      String nameToRegister = args[2 - offset];
      PhoneNumber phoneNumber = new PhoneNumber(
        Integer.parseInt(args[8 - offset]),
        args[9 - offset],
        args[10 - offset]);
      Address address = new Address(Integer.parseInt(args[3 - offset]),
                                    args[4 - offset],
                                    args[5 - offset],
                                    args[6 - offset],
                                    Integer.parseInt(args[7 - offset]),
                                    phoneNumber);
      SOAPMappingRegistry smr = new SOAPMappingRegistry();
      BeanSerializer beanSer = new BeanSerializer();
  
      // Map the types.
      smr.mapTypes(Constants.NS_URI_SOAP_ENC,
                   new QName("urn:ibm-soap-address-demo", "address"),
                   Address.class, beanSer, beanSer);
      smr.mapTypes(Constants.NS_URI_SOAP_ENC,
                   new QName("urn:ibm-soap-address-demo", "phone"),
                   PhoneNumber.class, beanSer, beanSer);
  
      // Build the call.
      Call call = new Call();
  
      call.setSOAPMappingRegistry(smr);
      call.setTargetObjectURI("urn:AddressFetcher");
      call.setMethodName("addEntry");
      call.setEncodingStyleURI(encodingStyleURI);
  
      Vector params = new Vector();
  
      params.addElement(new Parameter("nameToRegister", String.class,
                                      nameToRegister, null));
      params.addElement(new Parameter("address", Address.class,
                                      address, null));
      call.setParams(params);
  
      // Invoke the call.
      Response resp;
  
      try
      {
        resp = call.invoke(url, "");
      }
      catch (SOAPException e)
      {
        System.err.println("Caught SOAPException (" +
                           e.getFaultCode() + "): " +
                           e.getMessage());
        return;
      }
  
      // Check the response.
      if (!resp.generatedFault())
      {
        System.out.println(nameToRegister + " has been added.");
      }
      else
      {
        Fault fault = resp.getFault();
  
        System.err.println("Generated fault: ");
        System.out.println ("  Fault Code   = " + fault.getFaultCode());  
        System.out.println ("  Fault String = " + fault.getFaultString());
      }
    }
  }
  
  
  1.1                  xml-soap/java/samples/addressbook/README
  
  Index: README
  ===================================================================
  
  Service:
  -------
  
  To install this service on a IBM-SOAP listener, you need to make
  the demos.addressbook package available on the IBM-SOAP listener's
  classpath. Then deploy this service by filling in the deployment
  template using the info in the deployment descriptor in this
  directory.
  
  
  Client:
  ------
  
  There are 2 sample clients:
  
    java demos.addressbook.GetAddress
    java demos.addressbook.PutAddress
  
    Run either one with no args to see the usage.
  
  
  Additional Client Classpath Requirements:
  ----------------------------------------
  
    ../..
  
  
  Explanation:
  -----------
  
  This is a simple service that allows a client to query and populate an
  address book residing on a server. The address book is pre-populated
  with one name: John B. Good
  
  
  Sample Usage:
  ------------
  
  java demos.addressbook.GetAddress \
    http://localhost:2020/ibm-soap/rpcrouter.jsp "John B. Good"
  
  
  
  1.1                  xml-soap/java/samples/calculator/Calculator.java
  
  Index: Calculator.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.calculator;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import java.awt.*;
  import java.awt.event.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.rpc.*;
  
  /**
   * This silly little calculator talks to a SOAP calculator service to
   * do the real operations. 
   */
  public class Calculator extends Frame {
    String encodingStyleURI;
    URL url;
    TextField ef = new TextField ();
    int state = 0; // 0 => got 0 args, 1 => got 1 arg
    double arg1 = Double.NaN;
    boolean dotpressed = false;
    String lastop;
    Label status;
    boolean freshstart = true;
  
    public Calculator (String title) {
      super (title);
  
      addWindowListener (new WindowAdapter () {
        public void windowClosing (WindowEvent e) {
  	System.exit (0);
        }
      });
  
      ef.setEditable (false);
      add ("North", ef);
  
      Panel p = new Panel ();
      p.setLayout (new GridLayout (-1, 4, 5, 5));
      String bs[] = {"7", "8", "9", "/", 
  		   "4", "5", "6", "*",
  		   "1", "2", "3", "-",
  		   "0", "+/-", ".", "+"};
      for (int i = 0; i < bs.length; i++) {
        Button b = new Button (" " + bs[i] + " ");
        ActionListener al = null;
        if ((i != 3) && (i != 7) && (i != 11) && (i != 13) && (i != 14) && 
  	  (i != 15)) {
  	// digit pressed
  	b.setActionCommand (bs[i]);
  	al = new ActionListener () {
  	  public void actionPerformed (ActionEvent e) {
  	    if (freshstart) {
  	      ef.setText ("");
  	      freshstart = false;
  	    }
  	    Button bb = (Button) e.getSource ();
  	    ef.setText (ef.getText () + bb.getActionCommand ());
  	    status.setText ("");
  	  }
  	};
        } else if (i == 14) {
  	// '.' pressed
  	al = new ActionListener () {
  	  public void actionPerformed (ActionEvent e) {
  	    if (freshstart) {
  	      ef.setText ("");
  	      freshstart = false;
  	    }
  	    status.setText ("");
  	    if (dotpressed) {
  	      return;
  	    } else {
  	      dotpressed = true;
  	      ef.setText (ef.getText () + '.');
  	    }
  	  }
  	};
        } else if (i == 13) {
  	// +/- pressed
  	al = new ActionListener () {
  	  public void actionPerformed (ActionEvent e) {
  	    if (freshstart) {
  	      ef.setText ("");
  	      freshstart = false;
  	    }
  	    String t = ef.getText ();
  	    if (t.charAt (0) == '-') {
  	      ef.setText (t.substring (1));
  	    } else {
  	      ef.setText ('-' + t);
  	    }
  	    status.setText ("");
  	  }
  	};
        } else {
  	// operation
  	String ac = null;
  	if (bs[i].equals ("/")) {
  	  ac = "divide";
  	} else if (bs[i].equals ("*")) {
  	  ac = "times";
  	} else if (bs[i].equals ("-")) {
  	  ac = "minus";
  	} else {
  	  ac = "plus";
  	}
  	b.setActionCommand (ac);
  	al = new ActionListener () {
  	  public void actionPerformed (ActionEvent e) {
  	    Button bb = (Button) e.getSource ();
  	    double arg = stringToDouble (ef.getText ());
  	    if (state == 0) {
  	      arg1 = arg;
  	      lastop = bb.getActionCommand ();
  	      freshstart = true;
  	      state = 1;
  	    } else {
  	      try {
  		status.setText ("Working ..");
  		arg1 = doOp (lastop, arg1, arg);
  		lastop = bb.getActionCommand ();
  		ef.setText ("" + arg1);
  		freshstart = true;
  		status.setText ("");
  	      } catch (SOAPException e2) {
  		status.setText ("Ouch, excepted: " + e2.getMessage ());
  		e2.printStackTrace ();
  	      }
  	    }
  	  }
  	};
        }
        b.addActionListener (al);
        p.add (b);
      }
  
      add ("Center", p);
      add ("South", status = new Label ("Ready .."));
  
      pack ();
      show ();
    }
  
    private double doOp (String op, double arg1, double arg2) 
         throws SOAPException {
      // Build the call.
      Call call = new Call ();
      call.setTargetObjectURI ("urn:ibm-soap-demo-calculator");
      call.setMethodName (op);
      call.setEncodingStyleURI(encodingStyleURI);
      Vector params = new Vector ();
      params.addElement (new Parameter("arg1", double.class, 
  				     new Double (arg1), null));
      params.addElement (new Parameter("arg2", double.class, 
  				     new Double (arg2), null));
      call.setParams (params);
      
      // make the call: note that the action URI is empty because the 
      // IBM-SOAP rpc router does not need this. This may change in the
      // future.
      Response resp = call.invoke (/* router URL */ url, /* actionURI */ "" );
      
      // Check the response.
      if (resp.generatedFault ()) {
        Fault fault = resp.getFault ();
        System.out.println ("Ouch, the call failed: ");
        System.out.println ("  Fault Code   = " + fault.getFaultCode ());  
        System.out.println ("  Fault String = " + fault.getFaultString ());
        return Double.NaN;
      } else {
        Parameter result = resp.getReturnValue ();
        return ((Double)result.getValue ()).doubleValue ();
      }
    }
  
    private double stringToDouble (String s) {
      // try as a double, float or by appending a ".0" to it
      try {
        return Double.valueOf (s).doubleValue ();
      } catch (NumberFormatException e1) {
        try {
  	return Float.valueOf (s).floatValue () * 1.0;
        } catch (NumberFormatException e2) {
  	if (s.indexOf (".") == -1) {
  	  return stringToDouble (s + '.' + '0');
  	} else {
  	  return Double.NaN;
  	}
        }
      }
    }
  
    public static void main (String[] args) throws Exception {
      int maxargs = 2;
      if (args.length != (maxargs-1)
          && (args.length != maxargs || !args[0].startsWith ("-"))) {
        System.err.println ("Usage: java " + Calculator.class.getName () +
                            " [-encodingStyleURI] SOAP-router-URL");
        System.exit (1);
      }
  
      Calculator c = new Calculator ("IBM-SOAP Calculator");
  
      int offset = maxargs - args.length;
      c.encodingStyleURI = (args.length == maxargs)
                           ? args[0].substring(1)
                           : Constants.NS_URI_SOAP_ENC;
      c.url = new URL (args[1 - offset]);
    }
  }
  
  
  
  1.1                  xml-soap/java/samples/calculator/DeploymentDescriptor.xml
  
  Index: DeploymentDescriptor.xml
  ===================================================================
  <?xml version="1.0"?>
  
  <isd:service xmlns:isd="http://www.ibm.com/namespaces/ibm-soap/deployment"
               id="urn:ibm-soap-demo-calculator">
    <isd:provider type="script"
                  scope="Application" 
                  methods="plus minus times divide">
      <isd:script language="javascript">
        function plus (x, y) {
          return x + y;
        }
        
        function minus (x, y) {
          return x - y;
        }
        
        function times (x, y) {
          return x * y;
        }
        
        function divide (x, y) {
          return x / y;
        }
      </isd:script>
    </isd:provider>
  </isd:service>
  
  
  
  1.1                  xml-soap/java/samples/calculator/README
  
  Index: README
  ===================================================================
  
  Service:
  -------
  
  To install this service on a IBM-SOAP listener, you need to make
  the demos.addressbook package available on the IBM-SOAP listener's
  classpath. Then deploy this service by filling in the deployment
  template using the info in the deployment descriptor in this
  directory or by using the service manager client:
    java org.apache.soap.server.ServiceManagerClient routerURL deploy dd.xml
  where routerURL is the URL of the SOAP RPC router and dd.xml is the 
  name of the deployment descriptor file.
  
  
  Client:
  ------
  
  java demos.calculator.Calculator routerURL
  
  
  Additional Client Classpath Requirements:
  ----------------------------------------
  
    ../..
  
  
  Explanation:
  -----------
  
  This is a simple calculator client that talks to a Calculator service
  implemented in JavaScript. Enter a number by clicking the buttons, 
  click the operation, enter another number and click the next
  operation to apply the first. Now enter another number etc. ..
  
  
  
  Sample Usage:
  ------------
  
  java demos.calculator.Calculator \
    http://localhost:2020/ibm-soap/rpcrouter.jsp
  
  
  
  1.1                  xml-soap/java/samples/stockquote/DeploymentDescriptor.xml
  
  Index: DeploymentDescriptor.xml
  ===================================================================
  <isd:service xmlns:isd="http://www.ibm.com/namespaces/ibm-soap/deployment"
               id="urn:i3solutions-delayed-quotes">
    <isd:provider type="java"
                  scope="Application"
                  methods="getQuote">
      <isd:java class="demos.stockquote.StockQuoteService"/>
    </isd:provider>
  </isd:service>
  
  
  
  1.1                  xml-soap/java/samples/stockquote/GetQuote.java
  
  Index: GetQuote.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.stockquote;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.rpc.*;
  
  /**
   * See README for info.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class GetQuote {
    static XMLParserLiaison xpl = new XercesParserLiaison ();
  
    public static void main (String[] args) throws Exception {
      if (args.length != 2
          && (args.length != 3 || !args[0].startsWith ("-"))) {
        System.err.println ("Usage: java " + GetQuote.class.getName () +
                            " [-encodingStyleURI] SOAP-router-URL symbol");
        System.exit (1);
      }
  
      // Process the arguments.
      int offset = 3 - args.length;
      String encodingStyleURI = args.length == 3
                                ? args[0].substring(1)
                                : Constants.NS_URI_SOAP_ENC;
      URL url = new URL (args[1 - offset]);
      String symbol = args[2 - offset];
  
      // Build the call.
      Call call = new Call ();
      call.setTargetObjectURI ("urn:i3solutions-delayed-quotes");
      call.setMethodName ("getQuote");
      call.setEncodingStyleURI(encodingStyleURI);
      Vector params = new Vector ();
      params.addElement (new Parameter("symbol", String.class, symbol, null));
      call.setParams (params);
  
      // make the call: note that the action URI is empty because the 
      // IBM-SOAP rpc router does not need this. This may change in the
      // future.
      Response resp = call.invoke (/* router URL */ url, /* actionURI */ "" );
  
      // Check the response.
      if (resp.generatedFault ()) {
        Fault fault = resp.getFault ();
        System.out.println ("Ouch, the call failed: ");
        System.out.println ("  Fault Code   = " + fault.getFaultCode ());  
        System.out.println ("  Fault String = " + fault.getFaultString ());
      } else {
        Parameter result = resp.getReturnValue ();
        System.out.println (result.getValue ());
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/samples/stockquote/GetQuoteSMTP.java
  
  Index: GetQuoteSMTP.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.stockquote;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.transport.*;
  import org.apache.soap.transport.smtp.*;
  import org.apache.soap.rpc.*;
  
  /**
   * This shows how to get invoke the stockquote service using
   * SOAP over SMTP. I gave up on command line args for this and
   * decided to prompt for the info .. just too much stuff to 
   * set up. 
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class GetQuoteSMTP {
    static XMLParserLiaison xpl = new XercesParserLiaison ();
  
    public static void main (String[] args) throws Exception {
      if (args.length != 7
          && (args.length != 8 || !args[0].startsWith ("-"))) {
        System.err.println ("Usage: java " + GetQuoteSMTP.class.getName () +
                            " [-encodingStyleURI] routerURL smtpserver" +
  			  " replyaddr popserver poplogin poppasswd symbol");
        System.err.println ("  where:");
        System.err.println ("    routerURL   mailto: URL of SOAP router");
        System.err.println ("    smtpserver  SMTP server host name");
        System.err.println ("    replyaddr   email addr that response should " +
  			  "be sent to (my address)");
        System.err.println ("    popserver   POP server host name");
        System.err.println ("    poplogin    login ID to get response email");
        System.err.println ("    poppasswd   password for above");
        System.err.println ("    symbol      stock symbol");
        System.exit (1);
      }
  
      // Process the arguments.
      int offset = 8 - args.length;
      String encodingStyleURI = args.length == 8
                                ? args[0].substring(1)
                                : Constants.NS_URI_SOAP_ENC;
      URL url = new URL (args[1 - offset]);
      String smtpserver = args[2 - offset];
      String replyaddr = args[3 - offset];
      String popserver = args[4 - offset];
      String poplogin = args[5 - offset];
      String poppasswd = args[6 - offset];
      String symbol = args[7 - offset];
  
      // Build the call.
      SOAPTransport ss = new SOAPSMTPConnection (/* from address */ replyaddr, 
  					       /* subject */ "SOAP Request",
  					       /* smtpServer */ smtpserver,
  					       /* popPollDelay */ 20000,
  					       /* popServer */ popserver,
  					       /* popLogin */ poplogin,
  					       /* popPassword */ poppasswd);
      Call call = new Call ();
      call.setSOAPTransport (ss);
      call.setTargetObjectURI ("urn:i3solutions-delayed-quotes");
      call.setMethodName ("getQuote");
      call.setEncodingStyleURI(encodingStyleURI);
      Vector params = new Vector ();
      params.addElement (new Parameter ("symbol", String.class, symbol, null));
      call.setParams (params);
  
      // make the call: note that the action URI is empty because the 
      // IBM-SOAP rpc router does not need this. This may change in the
      // future.
      Response resp = call.invoke (/* router URL */ url, /* actionURI */ "" );
  
      // Check the response.
      if (resp.generatedFault ()) {
        Fault fault = resp.getFault ();
        System.out.println ("Ouch, the call failed: ");
        System.out.println ("  Fault Code   = " + fault.getFaultCode ());  
        System.out.println ("  Fault String = " + fault.getFaultString ());
      } else {
        Parameter result = resp.getReturnValue ();
        System.out.println (result.getValue ());
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/samples/stockquote/README
  
  Index: README
  ===================================================================
  
  Service:
  -------
  
  To install this service on a IBM-SOAP listener, you need to make
  the demos.stockquote.GetQuote class available on the
  IBM-SOAP listener's classpath. Then deploy this service by filling
  in the deployment template using the info in the deployment
  descriptor in this directory.
  
  
  Client:
  ------
  
  There are two clients- one that uses HTTP and one that uses SMTP
  as the transport. Run the following client to see the HTTP usage:
  
    java demos.stockquote.GetQuote
  
  Run the following client to see the SMTP usage:
  
    java demos.stockquote.GetQuoteSMTP
  
  
  Additional Client Classpath Requirements:
  ----------------------------------------
  
    ../..
  
  
  Explanation:
  -----------
  
  Retrieves a 20-min delayed quote for a ticker symbol.
  
  
  Sample Usage:
  ------------
  
  java demos.stockquote.GetQuote \
    http://localhost:2020/ibm-soap/rpcrouter.jsp IBM
  
  java demos.stockquote.GetQuoteSMTP \
    mailto:soaprouter@quoteserver.com smtpserver.myplace.com \
    me@myplace.com popserver.myplace.com me my-password IBM
  
  
  
  1.1                  xml-soap/java/samples/stockquote/StockQuoteService.java
  
  Index: StockQuoteService.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 demos.stockquote;
  
  import java.net.URL;
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.util.DOMUtils;
  
  /**
   * See \demos\stockquote\readme for info.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class StockQuoteService {
    XMLParserLiaison xpl = new XercesParserLiaison ();
  
    public float getQuote (String symbol) throws Exception {
      // get a real (delayed by 20min) stockquote from 
      // http://www.i3solutions.com/quote.asp. The IP addr 
      // below came from the host that the above form posts to ..
      URL url = new URL ("http://38.203.242.4/i3localweb/ProcessQuote.asp?txtQuery="+symbol);
      InputStream is = url.openStream ();
      Document d = xpl.read ("stock quote", new InputStreamReader (is));
      Element e = d.getDocumentElement ();
      NodeList nl = e.getElementsByTagName ("price");
      e = (Element) nl.item (0);
      String quoteStr = DOMUtils.getChildCharacterData (e);
      try {
        return Float.valueOf (quoteStr).floatValue ();
      } catch (NumberFormatException e1) {
        // mebbe its an int?
        try {
  	return Integer.valueOf (quoteStr).intValue () * 1.0F;
        } catch (NumberFormatException e2) {
  	return -1.0F;
        }
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/AttributeHandler.java
  
  Index: AttributeHandler.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  
  /**
   * An <code>AttributeHandler</code> maintains attributes and namespace
   * declarations for the other <em>SOAP</em> classes.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  class AttributeHandler
  {
    private Hashtable attributes             = new Hashtable();
    private Hashtable namespaceURIs2Prefixes = new Hashtable();
    private int       nsPrefixIndex          = 0;
  
    public AttributeHandler()
    {
      // Make sure to use "xmlns" as the prefix for any namespace declarations.
      namespaceURIs2Prefixes.put(Constants.NS_URI_XMLNS,
                                 Constants.NS_PRE_XMLNS);
    }
  
    public void setAttribute(QName attrQName, String value)
    {
      attributes.put(attrQName, value);
  
      // If this is a namespace declaration, register the new prefix.
      if (attrQName.getNamespaceURI().equals(Constants.NS_URI_XMLNS))
      {
        namespaceURIs2Prefixes.put(value, attrQName.getLocalPart());
      }
    }
  
    public String getAttribute(QName attrQName)
    {
      return (String)attributes.get(attrQName);
    }
  
    public void removeAttribute(QName attrQName)
    {
      attributes.remove(attrQName);
    }
  
    private Enumeration getAttributeQNames()
    {
      generateNSDeclarations();
  
      return attributes.keys();
    }
  
    public void declareNamespace(String nsPrefix, String namespaceURI)
    {
      setAttribute(new QName(Constants.NS_URI_XMLNS, nsPrefix), namespaceURI);
    }
  
    private void generateNSDeclarations()
    {
      Enumeration keys = attributes.keys();
  
      while (keys.hasMoreElements())
      {
        QName qname = (QName)keys.nextElement();
  
        // Ensure that a prefix has been associated with this namespace URI.
        getPrefixFromURI(qname.getNamespaceURI());
      }
    }
  
    private String getPrefixFromURI(String namespaceURI)
    {
      String nsPrefix = (String)namespaceURIs2Prefixes.get(namespaceURI);
  
      if (nsPrefix == null)
      {
        nsPrefix = "ns" + nsPrefixIndex++;
  
        setAttribute(new QName(Constants.NS_URI_XMLNS, nsPrefix), namespaceURI);
      }
  
      return nsPrefix;
    }
  
    public void populateNSStack(NSStack nsStack)
    {
      generateNSDeclarations();
  
      nsStack.pushScope();
  
      Enumeration e = namespaceURIs2Prefixes.keys();
  
      while (e.hasMoreElements())
      {
        String namespaceURI = (String)e.nextElement();
        String namespacePrefix = getPrefixFromURI(namespaceURI);
  
        nsStack.addNSDeclaration(namespacePrefix, namespaceURI);
      }
    }
  
    public String getUniquePrefixFromURI(String namespaceURI,
                                         String preferredPrefix,
                                         NSStack nsStack)
    {
      String retPrefix = nsStack.getPrefixFromURI(namespaceURI);
  
      if (retPrefix == null)
      {
        int prefixCount = 0;
  
        if (preferredPrefix == null)
        {
          preferredPrefix = "ns";
          prefixCount++;
        }
  
        while (retPrefix == null)
        {
          String newPrefix = preferredPrefix + (prefixCount > 0
                                                ? prefixCount + ""
                                                : "");
  
          // Is this prefix free?
          if (nsStack.getURIFromPrefix(newPrefix) == null)
          {
            // Have to declare the namespace, and update the namespace stack.
            nsStack.popScope();
            declareNamespace(newPrefix, namespaceURI);
            populateNSStack(nsStack);
            retPrefix = nsStack.getPrefixFromURI(namespaceURI);
          }
          else
          {
            prefixCount++;
          }
        }
      }
  
      return retPrefix;
    }
  
    public void marshall(Writer sink) throws IllegalArgumentException,
                                             IOException
    {
      Enumeration attrQNames = getAttributeQNames();
  
      while (attrQNames.hasMoreElements())
      {
        QName attrQName = (QName)attrQNames.nextElement();
  
        sink.write(' ' + getPrefixFromURI(attrQName.getNamespaceURI()) +
                   ':' + attrQName.getLocalPart() + "=\"" +
                   getAttribute(attrQName) + '\"');
      }
    }
  
    public static AttributeHandler unmarshall(Node src)
      throws IllegalArgumentException
    {
      NamedNodeMap attrs = src.getAttributes();
      AttributeHandler attrHandler = new AttributeHandler();
      int size = attrs.getLength();
  
      for (int i = 0; i < size; i++)
      {
        Attr attr = (Attr)attrs.item(i);
        String namespaceURI = attr.getNamespaceURI();
        String localName = attr.getLocalName();
        String value = attr.getValue();
  
        attrHandler.setAttribute(new QName(namespaceURI, localName), value);
      }
  
      return attrHandler;
    }
  
    public String toString()
    {
      StringWriter sw = new StringWriter();
  
      try
      {
        sw.write("{");
        marshall(sw);
        sw.write("}");
      }
      catch (Exception e)
      {
      }
  
      return sw.toString();
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/Body.java
  
  Index: Body.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.encoding.*;
  
  /**
   * A <code>Body</code> object represents the contents and semantics
   * of a <code>&lt;SOAP-ENV:Body&gt;</code> element.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class Body
  {
    private Vector           bodyEntries = null;
    private AttributeHandler attrHandler = new AttributeHandler();
  
    public void setAttribute(QName attrQName, String value)
    {
      attrHandler.setAttribute(attrQName, value);
    }
  
    public String getAttribute(QName attrQName)
    {
      return attrHandler.getAttribute(attrQName);
    }
  
    public void removeAttribute(QName attrQName)
    {
      attrHandler.removeAttribute(attrQName);
    }
  
    public void declareNamespace(String nsPrefix, String namespaceURI)
    {
      attrHandler.declareNamespace(nsPrefix, namespaceURI);
    }
  
    public void setBodyEntries(Vector bodyEntries)
    {
      this.bodyEntries = bodyEntries;
    }
  
    public Vector getBodyEntries()
    {
      return bodyEntries;
    }
  
    public void marshall(String inScopeEncStyle, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      attrHandler.populateNSStack(nsStack);
  
      String declEncStyle = getAttribute(new QName(
        Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE));
      String actualEncStyle = declEncStyle != null
                              ? declEncStyle
                              : inScopeEncStyle;
  
      // Determine the prefix associated with the NS_URI_SOAP_ENV namespace URI.
      String soapEnvNSPrefix = attrHandler.getUniquePrefixFromURI(
        Constants.NS_URI_SOAP_ENV, Constants.NS_PRE_SOAP_ENV, nsStack);
  
      sink.write('<' + soapEnvNSPrefix + ':' + Constants.ELEM_BODY);
  
      // Serialize any body attributes.
      attrHandler.marshall(sink);
  
      sink.write('>' + StringUtils.lineSeparator);
  
      // Serialize any body entries.
      if (bodyEntries != null)
      {
        for (Enumeration e = bodyEntries.elements(); e.hasMoreElements();)
        {
          Bean bodyEntry = (Bean)e.nextElement();
  
          if (Serializer.class.isAssignableFrom(bodyEntry.type))
          {
            ((Serializer)bodyEntry.value).marshall(actualEncStyle,
                                                   bodyEntry.type,
                                                   bodyEntry.value,
                                                   null,
                                                   sink,
                                                   nsStack,
                                                   xjmr);
          }
          else
          {
            throw new IllegalArgumentException("Body entries must implement " +
                                               "the Serializer interface.");
          }
        }
      }
  
      sink.write("</" + soapEnvNSPrefix + ':' + Constants.ELEM_BODY + '>' +
                 StringUtils.lineSeparator);
  
      nsStack.popScope();
    }
  
    public static Body unmarshall(Node src) throws IllegalArgumentException
    {
      Element root         = (Element)src;
      Body    body         = new Body();
      Vector  bodyEntries  = new Vector();
  
      // Deserialize any body attributes.
      body.attrHandler = AttributeHandler.unmarshall(root);
  
      for (Element el = DOMUtils.getFirstChildElement(root);
                   el != null;
                   el = DOMUtils.getNextSiblingElement(el))
      {
        bodyEntries.addElement(el);
      }
  
      body.setBodyEntries(bodyEntries);
  
      return body;
    }
  
    public String toString()
    {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
  
      pw.print("[Attributes=" + attrHandler + "] " +
               "[BodyEntries=");
  
      if (bodyEntries != null)
      {
        pw.println();
  
        for (int i = 0; i < bodyEntries.size(); i++)
        {
          pw.println("[(" + i + ")=" + bodyEntries.elementAt(i) + "]");
        }
      }
  
      pw.print("]");
  
      return sw.toString();
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/Constants.java
  
  Index: Constants.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap;
  
  import org.apache.soap.util.xml.QName;
  
  /**
   * <em>SOAP</em> constants.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class Constants
  {
    // Namespace prefixes.
    public static String NS_PRE_XMLNS = "xmlns";
    public static String NS_PRE_SOAP = "SOAP";
    public static String NS_PRE_SOAP_ENV = NS_PRE_SOAP + "-ENV";
    public static String NS_PRE_SOAP_ENC = NS_PRE_SOAP + "-ENC";
    public static String NS_PRE_SCHEMA_XSI = "xsi";
    public static String NS_PRE_SCHEMA_XSD = "xsd";
  
    // Namespace URIs.
    public static String NS_URI_XMLNS =
      "http://www.w3.org/2000/xmlns/";
    public static String NS_URI_SOAP_ENV =
      "http://schemas.xmlsoap.org/soap/envelope/";
    public static String NS_URI_SOAP_ENC =
      "http://schemas.xmlsoap.org/soap/encoding/";
    public static String NS_URI_SCHEMA_XSI =
      "http://www.w3.org/1999/XMLSchema/instance/";
    public static String NS_URI_SCHEMA_XSD =
      "http://www.w3.org/1999/XMLSchema/";
    public static String NS_URI_IBM_SOAP = 
      "http://www.ibm.com/namespaces/ibm-soap";
    public static String NS_URI_IBM_DEPLOYMENT = 
      "http://www.ibm.com/namespaces/ibm-soap/deployment";
    public static String NS_URI_BML_ENC = 
      "http://www.ibm.com/namespaces/bml";
    public static String NS_URI_XMI_ENC = 
      "http://www.ibm.com/namespaces/xmi";
  
    // HTTP header field names.
    public static String HEADER_POST = "POST";
    public static String HEADER_HOST = "Host";
    public static String HEADER_CONTENT_TYPE = "Content-Type";
    public static String HEADER_CONTENT_LENGTH = "Content-Length";
    public static String HEADER_SOAP_ACTION = "SOAPAction";
  
    // HTTP header field values.
    public static String HEADERVAL_CONTENT_TYPE = "text/xml";
  
    // Element names.
    public static String ELEM_ENVELOPE = "Envelope";
    public static String ELEM_BODY = "Body";
    public static String ELEM_HEADER = "Header";
    public static String ELEM_FAULT = "Fault";
    public static String ELEM_FAULT_CODE = "faultcode";
    public static String ELEM_FAULT_STRING = "faultstring";
    public static String ELEM_FAULT_ACTOR = "faultactor";
    public static String ELEM_DETAIL = "detail";
  
    // Qualified element names.
    public static QName  Q_ELEM_ENVELOPE =
      new QName(NS_URI_SOAP_ENV, ELEM_ENVELOPE);
    public static QName  Q_ELEM_HEADER =
      new QName(NS_URI_SOAP_ENV, ELEM_HEADER);
    public static QName  Q_ELEM_BODY =
      new QName(NS_URI_SOAP_ENV, ELEM_BODY);
    public static QName  Q_ELEM_FAULT =
      new QName(NS_URI_SOAP_ENV, ELEM_FAULT);
  
    // Attribute names.
    public static String ATTR_ENCODING_STYLE = "encodingStyle";
    public static String ATTR_MUST_UNDERSTAND = "mustUnderstand";
    public static String ATTR_TYPE = "type";
    public static String ATTR_NULL = "null";
    public static String ATTR_ARRAY_TYPE = "arrayType";
  
    // Qualified attribute names.
    public static QName  Q_ATTR_MUST_UNDERSTAND =
      new QName(NS_URI_SOAP_ENV, ATTR_MUST_UNDERSTAND);
  
    // Attribute values.
    public static String ATTRVAL_TRUE = "true";
  
    // SOAP defined fault codes.
    public static String FAULT_CODE_VERSION_MISMATCH =
      NS_PRE_SOAP_ENV + ":VersionMismatch";
    public static String FAULT_CODE_MUST_UNDERSTAND =
      NS_PRE_SOAP_ENV + ":MustUnderstand";
    public static String FAULT_CODE_CLIENT = NS_PRE_SOAP_ENV + ":Client";
    public static String FAULT_CODE_SERVER = NS_PRE_SOAP_ENV + ":Server";
    public static String FAULT_CODE_PROTOCOL = NS_PRE_SOAP_ENV + ":Protocol";
  
    // Error messages.
    public static String ERR_MSG_VERSION_MISMATCH = FAULT_CODE_VERSION_MISMATCH +
                                                    ": Envelope element must " +
                                                    "be associated with " +
                                                    "the '" +
                                                    Constants.NS_URI_SOAP_ENV +
                                                    "' namespace.";
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/Envelope.java
  
  Index: Envelope.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.encoding.*;
  
  /**
   * An <code>Envelope</code> object represents the contents and semantics
   * of an <code>&lt;SOAP-ENV:Envelope&gt;</code> element.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class Envelope
  {
    private Header           header          = null;
    private Body             body            = null;
    private Vector           envelopeEntries = null;
    private AttributeHandler attrHandler     = new AttributeHandler();
  
    public Envelope()
    {
      // Declare the "SOAP-ENV" namespace.
      declareNamespace(Constants.NS_PRE_SOAP_ENV,
                       Constants.NS_URI_SOAP_ENV);
  
      // Declare the "xsi" namespace.
      declareNamespace(Constants.NS_PRE_SCHEMA_XSI,
                       Constants.NS_URI_SCHEMA_XSI);
  
      // Declare the "xsd" namespace.
      declareNamespace(Constants.NS_PRE_SCHEMA_XSD,
                       Constants.NS_URI_SCHEMA_XSD);
    }
  
    public void setAttribute(QName attrQName, String value)
    {
      attrHandler.setAttribute(attrQName, value);
    }
  
    public String getAttribute(QName attrQName)
    {
      return attrHandler.getAttribute(attrQName);
    }
  
    public void removeAttribute(QName attrQName)
    {
      attrHandler.removeAttribute(attrQName);
    }
  
    public void declareNamespace(String nsPrefix, String namespaceURI)
    {
      attrHandler.declareNamespace(nsPrefix, namespaceURI);
    }
  
    public void setHeader(Header header)
    {
      this.header = header;
    }
  
    public Header getHeader()
    {
      return header;
    }
  
    public void setBody(Body body)
    {
      this.body = body;
    }
  
    public Body getBody()
    {
      return body;
    }
  
    public void setEnvelopeEntries(Vector envelopeEntries)
    {
      this.envelopeEntries = envelopeEntries;
    }
  
    public Vector getEnvelopeEntries()
    {
      return envelopeEntries;
    }
  
    public void marshall(Writer sink, XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      // Initialize the namespace stack.
      NSStack nsStack = new NSStack();
  
      attrHandler.populateNSStack(nsStack);
  
      Header header          = getHeader();
      Body   body            = getBody();
      Vector envelopeEntries = getEnvelopeEntries();
      String declEncStyle    = getAttribute(new QName(
        Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE));
  
      // Determine the prefix associated with the NS_URI_SOAP_ENV namespace URI.
      String soapEnvNSPrefix = attrHandler.getUniquePrefixFromURI(
        Constants.NS_URI_SOAP_ENV, Constants.NS_PRE_SOAP_ENV, nsStack);
  
      sink.write('<' + soapEnvNSPrefix + ':' + Constants.ELEM_ENVELOPE);
  
      // Serialize any envelope attributes.
      attrHandler.marshall(sink);
  
      sink.write('>' + StringUtils.lineSeparator);
  
      // If there is a header, serialize it.
      if (header != null)
      {
        header.marshall(sink, nsStack, xjmr);
      }
  
      // There must always be a <SOAP-ENV:Body>.
      if (body != null)
      {
        body.marshall(declEncStyle, sink, nsStack, xjmr);
      }
      else
      {
        throw new IllegalArgumentException("An '" + Constants.Q_ELEM_ENVELOPE +
                                           "' must contain a: '" +
                                           Constants.Q_ELEM_BODY + "'.");
      }
  
      // Serialize any envelope entries (in addition to <SOAP-ENV:Body>).
      if (envelopeEntries != null)
      {
        for (Enumeration e = envelopeEntries.elements(); e.hasMoreElements();)
        {
          Element envelopeEntryEl = (Element)e.nextElement();
  
          Utils.marshallNode(envelopeEntryEl, sink);
  
          sink.write(StringUtils.lineSeparator);
        }
      }
  
      sink.write("</" + soapEnvNSPrefix + ':' + Constants.ELEM_ENVELOPE + '>');
    }
  
    public static Envelope unmarshall(Node src) throws IllegalArgumentException
    {
      Element  root = (Element)src;
      Envelope env  = new Envelope();
  
      if (Constants.Q_ELEM_ENVELOPE.matches(root))
      {
        // Deserialize any envelope attributes.
        env.attrHandler = AttributeHandler.unmarshall(root);
  
        // Examine the subelements of the envelope.
        Element headerEl = null;
        Element bodyEl   = null;
        Element tempEl   = DOMUtils.getFirstChildElement(root);
  
        if (Constants.Q_ELEM_HEADER.matches(tempEl))
        {
          headerEl = tempEl;
          tempEl = DOMUtils.getNextSiblingElement(tempEl);
        }
  
        if (Constants.Q_ELEM_BODY.matches(tempEl))
        {
          bodyEl = tempEl;
          tempEl = DOMUtils.getNextSiblingElement(tempEl);
        }
  
        // Deserialize any header entries.
        if (headerEl != null)
        {
          Header header = Header.unmarshall(headerEl);
  
          env.setHeader(header);
        }
  
        // Deserialize any body entries.
        if (bodyEl != null)
        {
          Body body = Body.unmarshall(bodyEl);
  
          env.setBody(body);
        }
        else
        {
          throw new IllegalArgumentException("An '" + Constants.Q_ELEM_ENVELOPE +
                                             "' element must contain a: '" +
                                             Constants.Q_ELEM_BODY +
                                             "' element.");
        }
  
        // Deserialize any envelope entries (in addition to <SOAP-ENV:Body>).
        if (tempEl != null)
        {
          Vector envelopeEntries = new Vector();
  
          while (tempEl != null)
          {
            envelopeEntries.addElement(tempEl);
            tempEl = DOMUtils.getNextSiblingElement(tempEl);
          }
  
          env.setEnvelopeEntries(envelopeEntries);
        }
      }
      else
      {
        String localName = root.getLocalName();
  
        if (localName != null && localName.equals(Constants.ELEM_ENVELOPE))
        {
          throw new IllegalArgumentException(Constants.ERR_MSG_VERSION_MISMATCH);
        }
        else
        {
          throw new IllegalArgumentException("Root element of a SOAP message " +
                                             "must be: '" +
                                             Constants.Q_ELEM_ENVELOPE + "'.");
        }
      }
  
      return env;
    }
  
    public String toString()
    {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
  
      pw.print("[Attributes=" + attrHandler + "] " +
               "[Header=" + header + "] " +
               "[Body=" + body + "] " +
               "[EnvelopeEntries=");
  
      if (envelopeEntries != null)
      {
        pw.println();
  
        for (int i = 0; i < envelopeEntries.size(); i++)
        {
          pw.println("[(" + i + ")=" +
               DOM2Writer.nodeToString((Element)envelopeEntries.elementAt(i)) +
               "]");
        }
      }
  
      pw.print("]");
  
      return sw.toString();
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/Fault.java
  
  Index: Fault.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.encoding.*;
  
  /**
   * A <code>Fault</code> object represents the contents and semantics
   * of a <code>&lt;SOAP-ENV:Fault&gt;</code> element.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class Fault
  {
    private String           faultCode     = null;
    private String           faultString   = null;
    private String           faultActorURI = null;
    private Vector           detailEntries = null;
    private Vector           faultEntries  = null;
    private AttributeHandler attrHandler   = new AttributeHandler();
  
    public void setAttribute(QName attrQName, String value)
    {
      attrHandler.setAttribute(attrQName, value);
    }
  
    public String getAttribute(QName attrQName)
    {
      return attrHandler.getAttribute(attrQName);
    }
  
    public void removeAttribute(QName attrQName)
    {
      attrHandler.removeAttribute(attrQName);
    }
  
    public void declareNamespace(String nsPrefix, String namespaceURI)
    {
      attrHandler.declareNamespace(nsPrefix, namespaceURI);
    }
  
    public void setFaultCode(String faultCode)
    {
      this.faultCode = faultCode;
    }
  
    public String getFaultCode()
    {
      return faultCode;
    }
  
    public void setFaultString(String faultString)
    {
      this.faultString = faultString;
    }
  
    public String getFaultString()
    {
      return faultString;
    }
  
    public void setFaultActorURI(String faultActorURI)
    {
      this.faultActorURI = faultActorURI;
    }
  
    public String getFaultActorURI()
    {
      return faultActorURI;
    }
  
    public void setDetailEntries(Vector detailEntries)
    {
      this.detailEntries = detailEntries;
    }
  
    public Vector getDetailEntries()
    {
      return detailEntries;
    }
  
    public void setFaultEntries(Vector faultEntries)
    {
      this.faultEntries = faultEntries;
    }
  
    public Vector getFaultEntries()
    {
      return faultEntries;
    }
  
    public void marshall(String inScopeEncStyle, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      attrHandler.populateNSStack(nsStack);
  
      String faultCode      = getFaultCode();
      String faultString    = getFaultString();
      String faultActorURI  = getFaultActorURI();
      Vector detailEntries  = getDetailEntries();
      Vector faultEntries   = getFaultEntries();
  
      // Determine the prefix associated with the NS_URI_SOAP_ENV namespace URI.
      String soapEnvNSPrefix = attrHandler.getUniquePrefixFromURI(
        Constants.NS_URI_SOAP_ENV, Constants.NS_PRE_SOAP_ENV, nsStack);
  
      // Generate the required <SOAP-ENV:Fault>, <faultcode> and
      // <faultstring> elements.
      sink.write('<' + soapEnvNSPrefix + ':' + Constants.ELEM_FAULT);
  
      // Serialize any fault attributes.
      attrHandler.marshall(sink);
  
      sink.write('>' + StringUtils.lineSeparator +
                 '<' + Constants.ELEM_FAULT_CODE + '>' + faultCode +
                 "</" + Constants.ELEM_FAULT_CODE + '>' +
                 StringUtils.lineSeparator +
                 '<' + Constants.ELEM_FAULT_STRING + '>' + faultString +
                 "</" + Constants.ELEM_FAULT_STRING + '>' +
                 StringUtils.lineSeparator);
  
      // Generate the <faultactor> element if a value is present.
      if (faultActorURI != null)
      {
        sink.write('<' + Constants.ELEM_FAULT_ACTOR + '>' + faultActorURI +
                   "</" + Constants.ELEM_FAULT_ACTOR + '>' +
                   StringUtils.lineSeparator);
      }
  
      // If there are detail entries, generate the <detail> element,
      // and serialize the detail entries.
      if (detailEntries != null)
      {
        sink.write('<' + Constants.ELEM_DETAIL + '>' +
                   StringUtils.lineSeparator);
  
        // Serialize the detail entries within the <detail> element.
        for (Enumeration e = detailEntries.elements(); e.hasMoreElements();)
        {
          Element detailEntryEl = (Element)e.nextElement();
  
          Utils.marshallNode(detailEntryEl, sink);
  
          sink.write(StringUtils.lineSeparator);
        }
  
        sink.write("</" + Constants.ELEM_DETAIL + '>' +
                   StringUtils.lineSeparator);
      }
  
      // Serialize any fault entries (in addition to <faultcode>, <faultstring>,
      // <faultactor>, and <detail>).
      if (faultEntries != null)
      {
        for (Enumeration e = faultEntries.elements(); e.hasMoreElements();)
        {
          Element faultEntryEl = (Element)e.nextElement();
  
          Utils.marshallNode(faultEntryEl, sink);
  
          sink.write(StringUtils.lineSeparator);
        }
      }
  
      sink.write("</" + soapEnvNSPrefix + ':' + Constants.ELEM_FAULT + '>' +
                 StringUtils.lineSeparator);
  
      nsStack.popScope();
    }
  
    public static Fault unmarshall(String inScopeEncStyle, Node src,
                                   XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException
    {
      Element root  = (Element)src;
      Fault   fault = new Fault();
  
      if (Constants.Q_ELEM_FAULT.matches(root))
      {
        Element faultCodeEl   = null;
        Element faultStringEl = null;
        Element faultActorEl  = null;
        Element detailEl      = null;
        Vector  faultEntries  = new Vector();
        Element tempEl        = DOMUtils.getFirstChildElement(root);
  
        // Deserialize any fault attributes.
        fault.attrHandler = AttributeHandler.unmarshall(root);
  
        // Examine the subelements of the fault.
        while (tempEl != null)
        {
          if (tempEl != null
              && tempEl.getTagName().equals(Constants.ELEM_FAULT_CODE))
          {
            faultCodeEl = tempEl;
          }
          else if (tempEl != null
                   && tempEl.getTagName().equals(Constants.ELEM_FAULT_STRING))
          {
            faultStringEl = tempEl;
          }
          else if (tempEl != null
                   && tempEl.getTagName().equals(Constants.ELEM_FAULT_ACTOR))
          {
            faultActorEl = tempEl;
          }
          else if (tempEl != null
                   && tempEl.getTagName().equals(Constants.ELEM_DETAIL))
          {
            detailEl = tempEl;
          }
          else
          {
            // This must be an additional fault entry.
            faultEntries.addElement(tempEl);
          }
  
          tempEl = DOMUtils.getNextSiblingElement(tempEl);
        }
  
        // Deserialize the required <faultcode> element.
        if (faultCodeEl != null)
        {
          String faultCode = DOMUtils.getChildCharacterData(faultCodeEl);
  
          fault.setFaultCode(faultCode);
        }
        else
        {
          throw new IllegalArgumentException("A '" + Constants.Q_ELEM_FAULT +
                                             "' element must contain a: '" +
                                             Constants.ELEM_FAULT_CODE +
                                             "' element.");
        }
  
        // Deserialize the required <faultstring> element.
        if (faultStringEl != null)
        {
          String faultString = DOMUtils.getChildCharacterData(faultStringEl);
  
          fault.setFaultString(faultString);
        }
        else
        {
          throw new IllegalArgumentException("A '" + Constants.Q_ELEM_FAULT +
                                             "' element must contain a: '" +
                                             Constants.ELEM_FAULT_STRING +
                                             "' element.");
        }
  
        // Deserialize the <faultactor> element, if present.
        if (faultActorEl != null)
        {
          String faultActorURI = DOMUtils.getChildCharacterData(faultActorEl);
  
          fault.setFaultActorURI(faultActorURI);
        }
  
        // Deserialize any detail entries.
        if (detailEl != null)
        {
          Vector detailEntries = new Vector();
  
          for (Element el = DOMUtils.getFirstChildElement(detailEl);
                       el != null;
                       el = DOMUtils.getNextSiblingElement(el))
          {
            detailEntries.addElement(el);
          }
  
          fault.setDetailEntries(detailEntries);
        }
  
        // Set the faultEntries property, if any additional fault entries
        // were encountered.
        if (faultEntries.size() > 0)
        {
          fault.setFaultEntries(faultEntries);
        }
      }
      else
      {
        throw new IllegalArgumentException("Root element of a SOAP Fault " +
                                           "must be: '" +
                                           Constants.Q_ELEM_FAULT + "'.");
      }
  
      return fault;
    }
  
    public String toString()
    {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
  
      pw.print("[Attributes=" + attrHandler + "] " +
               "[faultCode=" + faultCode + "] " +
               "[faultString=" + faultString + "] " +
               "[faultActorURI=" + faultActorURI + "] " +
               "[DetailEntries=");
  
      if (detailEntries != null)
      {
        pw.println();
  
        for (int i = 0; i < detailEntries.size(); i++)
        {
          pw.println("[(" + i + ")=" +
                 DOM2Writer.nodeToString((Element)detailEntries.elementAt(i)) +
                 "]");
        }
      }
  
      pw.print("] [FaultEntries=");
  
      if (faultEntries != null)
      {
        pw.println();
  
        for (int i = 0; i < faultEntries.size(); i++)
        {
          pw.println("[(" + i + ")=" +
                  DOM2Writer.nodeToString((Element)faultEntries.elementAt(i)) +
                  "]");
        }
      }
  
      pw.print("]");
  
      return sw.toString();
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/Header.java
  
  Index: Header.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.encoding.*;
  
  /**
   * A <code>Header</code> object represents the contents and semantics
   * of a <code>&lt;SOAP-ENV:Header&gt;</code> element.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class Header
  {
    private Vector           headerEntries = null;
    private AttributeHandler attrHandler   = new AttributeHandler();
  
    public void setAttribute(QName attrQName, String value)
    {
      attrHandler.setAttribute(attrQName, value);
    }
  
    public String getAttribute(QName attrQName)
    {
      return attrHandler.getAttribute(attrQName);
    }
  
    public void removeAttribute(QName attrQName)
    {
      attrHandler.removeAttribute(attrQName);
    }
  
    public void declareNamespace(String nsPrefix, String namespaceURI)
    {
      attrHandler.declareNamespace(nsPrefix, namespaceURI);
    }
  
    public void setHeaderEntries(Vector headerEntries)
    {
      this.headerEntries = headerEntries;
    }
  
    public Vector getHeaderEntries()
    {
      return headerEntries;
    }
  
    public void marshall(Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      attrHandler.populateNSStack(nsStack);
  
      // Determine the prefix associated with the NS_URI_SOAP_ENV namespace URI.
      String soapEnvNSPrefix = attrHandler.getUniquePrefixFromURI(
        Constants.NS_URI_SOAP_ENV, Constants.NS_PRE_SOAP_ENV, nsStack);
  
      // If there are header entries, generate the <SOAP-ENV:Header> element,
      // and serialize the header entries.
      if (headerEntries != null)
      {
        sink.write('<' + soapEnvNSPrefix + ':' + Constants.ELEM_HEADER);
  
        // Serialize any header attributes.
        attrHandler.marshall(sink);
  
        sink.write('>' + StringUtils.lineSeparator);
  
        // Serialize the header entries within the <SOAP-ENV:Header> element.
        for (Enumeration e = headerEntries.elements(); e.hasMoreElements();)
        {
          Element headerEntryEl = (Element)e.nextElement();
  
          Utils.marshallNode(headerEntryEl, sink);
  
          sink.write(StringUtils.lineSeparator);
        }
  
        sink.write("</" + soapEnvNSPrefix + ':' + Constants.ELEM_HEADER +
                   '>' + StringUtils.lineSeparator);
      }
  
      nsStack.popScope();
    }
  
    public static Header unmarshall(Node src) throws IllegalArgumentException
    {
      Element root          = (Element)src;
      Header  header        = new Header();
      Vector  headerEntries = new Vector();
  
      // Deserialize any header attributes.
      header.attrHandler = AttributeHandler.unmarshall(root);
  
      for (Element el = DOMUtils.getFirstChildElement(root);
                   el != null;
                   el = DOMUtils.getNextSiblingElement(el))
      {
        headerEntries.addElement(el);
      }
  
      header.setHeaderEntries(headerEntries);
  
      return header;
    }
  
    public String toString()
    {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
  
      pw.print("[Attributes=" + attrHandler + "] " +
               "[HeaderEntries={");
  
      if (headerEntries != null)
      {
        for (int i = 0; i < headerEntries.size(); i++)
        {
          if (i > 0)
          {
            pw.print(", ");
          }
  
          pw.print("[" + headerEntries.elementAt(i) + "]");
        }
      }
  
      pw.print("}]");
  
      return sw.toString();
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/SOAPException.java
  
  Index: SOAPException.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap;
  
  /**
   * <em>SOAP</em> Exceptions.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class SOAPException extends Exception {
    private String faultCode;
    private Throwable targetException;
  
    public SOAPException (String faultCode, String msg) {
      super (msg);
      this.faultCode = faultCode;
    }
  
    public SOAPException (String faultCode, String msg,
                          Throwable targetException) {
      this (faultCode, msg);
      this.targetException = targetException;
    }
  
    public void setFaultCode (String faultCode) {
      this.faultCode = faultCode;
    }
  
    public String getFaultCode () {
      return faultCode;
    }
  
    public void setTargetException (Throwable targetException) {
      this.targetException = targetException;
    }
  
    public Throwable getTargetException () {
      return targetException;
    }
  
    public String getMessage () {
      String superMsg = super.getMessage ();
      String targetMsg = (targetException != null)
                         ? targetException.getMessage ()
                         : null;
      String msg = ((superMsg == null || superMsg.equals (""))
                    && (targetMsg != null && !targetMsg.equals ("")))
                   ? targetMsg
                   : superMsg;
  
      if (msg == null || msg.equals ("")) {
        msg = (targetException != null)
              ? targetException.toString()
              : this.toString();
      }
  
      return msg;
    }
  
    public String toString () {
      return "[SOAPException: faultCode=" + faultCode + "; msg=" +
             super.getMessage () + ((targetException != null)
             ? ("; targetException=" + targetException) : "") + "]";
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/Utils.java
  
  Index: Utils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap;
  
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  
  /**
   * <em>SOAP</em> utilities.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class Utils
  {
    public static String cleanString(String orig)
    {
      if (orig == null)
      {
        return "";
      }
  
      StringBuffer strBuf = new StringBuffer();
      char[] chars = orig.toCharArray();
  
      for (int i = 0; i < chars.length; i++)
      {
        switch (chars[i])
        {
          case '&'  : strBuf.append("&amp;");
                      break;
          case '\"' : strBuf.append("&quot;");
                      break;
          case '\'' : strBuf.append("&apos;");
                      break;
          case '<'  : strBuf.append("&lt;");
                      break;
          case '>'  : strBuf.append("&gt;");
                      break;
          default   : strBuf.append(chars[i]);
                      break;
        }
      }
  
      return strBuf.toString();
    }
  
    public static void marshallNode(Node node, Writer sink)
    {
      DOM2Writer.serializeAsXML(node, sink);
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/encoding/SOAPMappingRegistry.java
  
  Index: SOAPMappingRegistry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.encoding;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.rpc.*;
  import org.apache.soap.encoding.soapenc.*;
  import org.apache.soap.encoding.xmi.*;
  
  /**
   * A <code>SOAPMappingRegistry</code> object is an
   * <code>XMLJavaMappingRegistry</code> with pre-registered
   * serializers and deserializers to support <em>SOAP</em>.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Francisco Curbera (curbera@us.ibm.com)
   * @author Sam Ruby (rubys@us.ibm.com)
   */
  public class SOAPMappingRegistry extends XMLJavaMappingRegistry
  {
    private static final String soapEncURI = Constants.NS_URI_SOAP_ENC;
    private static final String schemaURI = Constants.NS_URI_SCHEMA_XSD;
    private static final QName stringQName = new QName(schemaURI, "string");
    private static final QName booleanQName = new QName(schemaURI, "boolean");
    private static final QName doubleQName = new QName(schemaURI, "double");
    private static final QName floatQName = new QName(schemaURI, "float");
    private static final QName longQName = new QName(schemaURI, "long");
    private static final QName intQName = new QName(schemaURI, "int");
    private static final QName shortQName = new QName(schemaURI, "short");
    private static final QName byteQName = new QName(schemaURI, "byte");
    private static final QName arrayQName = new QName(soapEncURI, "Array");
  
    private final ParameterSerializer paramSer = new ParameterSerializer();
    private final ArraySerializer arraySer = new ArraySerializer();
  
    public SOAPMappingRegistry()
    {
      // Register parameter serializer for SOAP-ENC encoding style.
      mapTypes(soapEncURI, RPCConstants.Q_ELEM_PARAMETER, Parameter.class,
               paramSer, paramSer);
  
      // Register array deserializer for SOAP-ENC encoding style.
      mapTypes(soapEncURI, arrayQName, null, null, arraySer);
  
      /*
        Map xsd:ur-type to java.lang.Object (no serializer/deserializer,
        just an association).
      */
      mapTypes(Constants.NS_URI_SOAP_ENC,
               new QName(Constants.NS_URI_SCHEMA_XSD, "ur-type"),
               Object.class, null, null);
  
  
      try {
  
        Class XMISerializer = Class.forName("org.apache.soap.util.xml.XMISerializer");
        Class XMIParameterSerializer = 
          Class.forName("org.apache.soap.encoding.xmi.XMIParameterSerializer");
  
        // Register default serializers for XMI encoding style.
        mapTypes(Constants.NS_URI_XMI_ENC, null, null,
                 (Serializer)XMISerializer.newInstance(), 
                 (Deserializer)XMIParameterSerializer.newInstance());
  
        // Register serializer for Parameter class - not deserializer!
        mapTypes(Constants.NS_URI_XMI_ENC, null, Parameter.class,
                 (Serializer)XMIParameterSerializer.newInstance(), null);
  
      } catch (IllegalAccessException iae) {
      } catch (InstantiationException ie) {
      } catch (ClassNotFoundException cnfe) {
  
        // If the class can't be loaded, continue without it...
  
      }
  
      Serializer ser = new Serializer()
      {
        public void marshall(String inScopeEncStyle, Class javaType, Object src,
                             Object context, Writer sink, NSStack nsStack,
                             XMLJavaMappingRegistry xjmr)
          throws IllegalArgumentException, IOException
        {
          nsStack.pushScope();
  
          SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                               javaType,
                                               context,
                                               sink,
                                               nsStack,
                                               xjmr);
  
          sink.write(src.toString() + "</" + context + '>');
  
          nsStack.popScope();
        }
      };
  
      Deserializer deser = new Deserializer()
      {
        public Bean unmarshall(String inScopeEncStyle, QName elementType,
                               Node src, XMLJavaMappingRegistry xjmr)
          throws IllegalArgumentException
        {
          Element root = (Element)src;
          String value = DOMUtils.getChildCharacterData(root);
  
          if (elementType.equals(stringQName))
          {
            return new Bean(String.class, value);
          }
          else if (elementType.equals(booleanQName))
          {
            return new Bean(boolean.class, new Boolean(value));
          }
          else if (elementType.equals(doubleQName))
          {
            return new Bean(double.class, new Double(value));
          }
          else if (elementType.equals(floatQName))
          {
            return new Bean(float.class, new Float(value));
          }
          else if (elementType.equals(longQName))
          {
            return new Bean(long.class, new Long(value));
          }
          else if (elementType.equals(intQName))
          {
            return new Bean(int.class, new Integer(value));
          }
          else if (elementType.equals(shortQName))
          {
            return new Bean(short.class, new Short(value));
          }
          else if (elementType.equals(byteQName))
          {
            return new Bean(byte.class, new Byte(value));
          }
  
          throw new IllegalArgumentException("I don't know how to " +
                                             "deserialize a '" + elementType +
                                             "' using encoding style '" +
                                             inScopeEncStyle + "'.");
        }
      };
  
      /*
        Register mapping of element type to/from Java type along with
        the serializer and deserializer for it. Note that we register
        the same serializer for primitives and their object wrapper
        counterparts. What this means is that once encoded into 
        SOAP_ENC, a primitive int and an Integer, for example, are
        indistinguishable. We believe (at least for now :-)) that this
        is the right thing to do .. that is, upon seeing an element
        like <foo xsi:type="xsd:int">53343</foo> we should always get
        a primitive int out of it.
      */
      mapTypes(soapEncURI, stringQName, String.class, ser, deser);
      mapTypes(soapEncURI, booleanQName, Boolean.class, ser, null);
      mapTypes(soapEncURI, booleanQName, boolean.class, ser, deser);
      mapTypes(soapEncURI, doubleQName, Double.class, ser, null);
      mapTypes(soapEncURI, doubleQName, double.class, ser, deser);
      mapTypes(soapEncURI, floatQName, Float.class, ser, null);
      mapTypes(soapEncURI, floatQName, float.class, ser, deser);
      mapTypes(soapEncURI, longQName, Long.class, ser, null);
      mapTypes(soapEncURI, longQName, long.class, ser, deser);
      mapTypes(soapEncURI, intQName, Integer.class, ser, null);
      mapTypes(soapEncURI, intQName, int.class, ser, deser);
      mapTypes(soapEncURI, shortQName, Short.class, ser, null);
      mapTypes(soapEncURI, shortQName, short.class, ser, deser);
      mapTypes(soapEncURI, byteQName, Byte.class, ser, null);
      mapTypes(soapEncURI, byteQName, byte.class, ser, deser);
    }
  
    /**
     * This function overrides the one in XMLJavaMappingRegistry for the sole
     * purpose of returning SOAP-ENC:Array when javaType represents an array.
     * The XMLJavaMappingRegistry will be consulted first, and if no mapping
     * is found, SOAP-ENC:Array is returned. Obviously, this only applies when
     * the encoding style is soap encoding.
     */
    public QName queryElementType(Class javaType, String encodingStyleURI)
      throws IllegalArgumentException
    {
      try
      {
        return super.queryElementType(javaType, encodingStyleURI);
      }
      catch (IllegalArgumentException e)
      {
        if (javaType != null
            && javaType.isArray()
            && encodingStyleURI != null
            && encodingStyleURI.equals(soapEncURI))
        {
          return arrayQName;
        }
        else
        {
          throw e;
        }
      }
    }
  
    /**
     * This function overrides the one in XMLJavaMappingRegistry for the sole
     * purpose of returning an ArraySerializer when javaType represents an
     * array. The XMLJavaMappingRegistry will be consulted first, and if no
     * serializer is found for javaType, ArraySerailizer is returned.
     * Obviously, this only applies when the encoding style is soap encoding.
     */
    public Serializer querySerializer(Class javaType, String encodingStyleURI)
      throws IllegalArgumentException
    {
      try
      {
        return super.querySerializer(javaType, encodingStyleURI);
      }
      catch (IllegalArgumentException e)
      {
        if (javaType != null
            && javaType.isArray()
            && encodingStyleURI != null
            && encodingStyleURI.equals(soapEncURI))
        {
          return arraySer;
        }
        else
        {
          throw e;
        }
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/encoding/soapenc/ArraySerializer.java
  
  Index: ArraySerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.encoding.soapenc;
  
  import java.beans.*;
  import java.io.*;
  import java.util.*;
  import java.lang.reflect.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.rpc.*;
  
  /**
   * A <code>ArraySerializer</code> can be used to serialize and deserialize
   * arrays using the <code>SOAP-ENC</code> encoding style.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class ArraySerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      String lengthStr = src != null
                         ? Array.getLength(src) + ""
                         : "";
      Class componentType = javaType.getComponentType();
      QName elementType = xjmr.queryElementType(componentType,
                                                Constants.NS_URI_SOAP_ENC);
  
      if (src == null)
      {
        SoapEncUtils.generateNullArray(inScopeEncStyle,
                                       javaType,
                                       context,
                                       sink,
                                       nsStack,
                                       xjmr,
                                       elementType,
                                       lengthStr);
      }
      else
      {
        SoapEncUtils.generateArrayHeader(inScopeEncStyle,
                                         javaType,
                                         context,
                                         sink,
                                         nsStack,
                                         xjmr,
                                         elementType,
                                         lengthStr);
  
        sink.write(StringUtils.lineSeparator);
  
        int length = Array.getLength(src);
  
        for (int i = 0; i < length; i++)
        {
          nsStack.pushScope();
  
          Object value = Array.get(src, i);
  
          if (value == null)
          {
            SoapEncUtils.generateNullStructure(inScopeEncStyle, componentType,
                                               "item", sink, nsStack, xjmr);
          }
          else
          {
            Class actualComponentType = value.getClass();
  
            xjmr.marshall(inScopeEncStyle, actualComponentType, value, "item",
                          sink, nsStack);
          }
  
          sink.write(StringUtils.lineSeparator);
          nsStack.popScope();
        }
  
        sink.write("</" + context + '>');
      }
  
      nsStack.popScope();
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException
    {
      Element root = (Element)src;
      String name = root.getTagName();
      QName arrayItemType = new QName("", "");
      Object array = getNewArray(inScopeEncStyle, root, arrayItemType, xjmr);
  
      if (SoapEncUtils.isNull(root))
      {
        return new Bean(array.getClass(), null);
      }
  
      Element tempEl = DOMUtils.getFirstChildElement(root);
      int length = Array.getLength(array);
  
      for (int i = 0; i < length; i++)
      {
        String declEncStyle = tempEl.getAttributeNS(
          Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
        String actualEncStyle = declEncStyle != null
                                ? declEncStyle
                                : inScopeEncStyle;
        QName declItemType = SoapEncUtils.getAttributeValue(tempEl,
          Constants.NS_URI_SCHEMA_XSI, Constants.ATTR_TYPE, "array item",
          false);
        QName actualItemType = declItemType != null
                               ? declItemType
                               : arrayItemType;
  
        Bean itemBean = xjmr.unmarshall(actualEncStyle, actualItemType, tempEl);
  
        Array.set(array, i, itemBean.value);
  
        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }
  
      return new Bean(array.getClass(), array);
    }
  
    public static Object getNewArray(String inScopeEncStyle, Element arrayEl,
                                     QName arrayItemType,
                                     XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException
    {
      QName arrayTypeValue = SoapEncUtils.getAttributeValue(arrayEl,
        Constants.NS_URI_SOAP_ENC, Constants.ATTR_ARRAY_TYPE, "array", true);
      String arrayTypeValueNamespaceURI = arrayTypeValue.getNamespaceURI();
      String arrayTypeValueLocalPart = arrayTypeValue.getLocalPart();
      int leftBracketIndex = arrayTypeValueLocalPart.lastIndexOf('[');
      int rightBracketIndex = arrayTypeValueLocalPart.lastIndexOf(']');
  
      if (leftBracketIndex == -1
          || rightBracketIndex == -1
          || rightBracketIndex < leftBracketIndex)
      {
        throw new IllegalArgumentException("Malformed arrayTypeValue '" +
                                           arrayTypeValue + "'.");
      }
  
      String componentTypeName =
        arrayTypeValueLocalPart.substring(0, leftBracketIndex);
  
      if (componentTypeName.endsWith("]"))
      {
        throw new IllegalArgumentException("Arrays of arrays are not " +
                                           "supported '" + arrayTypeValue +
                                           "'.");
      }
  
      arrayItemType.setNamespaceURI(arrayTypeValueNamespaceURI);
      arrayItemType.setLocalPart(componentTypeName);
  
      int length = DOMUtils.countKids(arrayEl, Node.ELEMENT_NODE);
      String lengthStr =
        arrayTypeValueLocalPart.substring(leftBracketIndex + 1,
                                          rightBracketIndex);
  
      if (lengthStr.length() > 0)
      {
        if (lengthStr.indexOf(',') != -1)
        {
          throw new IllegalArgumentException("Multi-dimensional arrays are " +
                                             "not supported '" +
                                             lengthStr + "'.");
        }
  
        try
        {
          int explicitLength = Integer.parseInt(lengthStr);
  
          if (length != explicitLength)
          {
            throw new IllegalArgumentException("Explicit array length is " +
                                               "not equal to the number of " +
                                               "items '" + explicitLength +
                                               " != " + length + "'.");
          }
        }
        catch (NumberFormatException e)
        {
          throw new IllegalArgumentException("Explicit array length is not a " +
                                             "valid integer '" + lengthStr +
                                             "'.");
        }
      }
  
      Class componentType = xjmr.queryJavaType(arrayItemType, inScopeEncStyle);
  
      return Array.newInstance(componentType, length);
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/encoding/soapenc/BeanSerializer.java
  
  Index: BeanSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.encoding.soapenc;
  
  import java.beans.*;
  import java.io.*;
  import java.util.*;
  import java.lang.reflect.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.rpc.*;
  
  /**
   * A <code>BeanSerializer</code> can be used to serialize and deserialize
   * <em>JavaBeans</em> using the <code>SOAP-ENC</code> encoding style. The
   * public properties of the bean become named accessors.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class BeanSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      SoapEncUtils.generateStructureHeader(inScopeEncStyle,
                                           javaType,
                                           context,
                                           sink,
                                           nsStack,
                                           xjmr);
  
      sink.write(StringUtils.lineSeparator);
  
      PropertyDescriptor[] properties = getPropertyDescriptors(javaType);
  
      for (int i = 0; i < properties.length; i++)
      {
        String propName = properties[i].getName();
        Class propType = properties[i].getPropertyType();
  
        // Serialize every property except the "class" property.
        if (!propType.equals(Class.class))
        {
          Method propReadMethod = properties[i].getReadMethod();
  
          // Only serialize readable properties.
          if (propReadMethod != null)
          {
            Object propValue = null;
  
            // Get the property's value.
            try
            {
              if (src != null)
              {
                propValue = propReadMethod.invoke(src, new Object[]{});
              }
            }
            catch (Exception e)
            {
              throw new IllegalArgumentException("Unable to retrieve '" +
                                                 propName + "' property " +
                                                 "value: " + e.getMessage() +
                                                 '.');
            }
  
            // Serialize the property.
            Parameter param = new Parameter(propName, propType, propValue, null);
  
            xjmr.marshall(inScopeEncStyle, Parameter.class, param, null,
                          sink, nsStack);
  
            sink.write(StringUtils.lineSeparator);
          }
        }
      }
  
      sink.write("</" + context + '>');
  
      nsStack.popScope();
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException
    {
      Element root = (Element)src;
      Element tempEl = DOMUtils.getFirstChildElement(root);
      Class javaType = xjmr.queryJavaType(elementType, inScopeEncStyle);
      Object bean = instantiateBean(javaType);
      PropertyDescriptor[] properties = getPropertyDescriptors(javaType);
  
      while (tempEl != null)
      {
        Bean paramBean = xjmr.unmarshall(inScopeEncStyle,
                                         RPCConstants.Q_ELEM_PARAMETER,
                                         tempEl);
        Parameter param = (Parameter)paramBean.value;
        Method propWriteMethod = getWriteMethod(param.getName(),
                                                properties,
                                                javaType);
  
        if (propWriteMethod != null)
        {
          // Set the property's value.
          try
          {
            propWriteMethod.invoke(bean, new Object[]{param.getValue()});
          }
          catch (Exception e)
          {
            throw new IllegalArgumentException("Unable to set '" +
                                               param.getName() +
                                               "' property: " +
                                               e.getMessage() + '.');
          }
        }
  
        tempEl = DOMUtils.getNextSiblingElement(tempEl);
      }
  
      return new Bean(javaType, bean);
    }
  
    private static PropertyDescriptor[] getPropertyDescriptors(Class javaType)
      throws IllegalArgumentException
    {
      BeanInfo beanInfo = null;
  
      try
      {
        beanInfo = Introspector.getBeanInfo(javaType);
      }
      catch (IntrospectionException e)
      {
      }
  
      if (beanInfo != null)
      {
        PropertyDescriptor[] properties = beanInfo.getPropertyDescriptors();
  
        if (properties != null)
        {
          return properties;
        }
        else
        {
          throw new IllegalArgumentException("Unable to retrieve property " +
                                             "descriptors for '" +
                                             StringUtils.getClassName(javaType) +
                                             "'.");
        }
      }
      else
      {
        throw new IllegalArgumentException("Unable to retrieve BeanInfo " +
                                           "for '" + StringUtils.getClassName(
                                           javaType) + "'.");
      }
    }
  
    private static Method getWriteMethod(String propertyName,
                                         PropertyDescriptor[] pds,
                                         Class javaType)
    {
      for (int i = 0; i < pds.length; i++)
      {
        if (propertyName.equals(pds[i].getName()))
        {
          return pds[i].getWriteMethod();
        }
      }
  
      throw new IllegalArgumentException("Unable to retrieve " +
                                         "PropertyDescriptor for property '" +
                                         propertyName + "' of class '" +
                                         javaType + "'.");
    }
  
    private static Object instantiateBean(Class javaType)
      throws IllegalArgumentException
    {
      try
      {
        return javaType.newInstance();
      }
      catch (Throwable t)
      {
        throw new IllegalArgumentException("Unable to instantiate '" +
                                           StringUtils.getClassName(javaType) +
                                           "': " + t.getMessage());
      }
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/encoding/soapenc/ParameterSerializer.java
  
  Index: ParameterSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.encoding.soapenc;
  
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.rpc.*;
  
  /**
   * A <code>ParameterSerializer</code> is used to serialize and deserialize
   * parameters using the <code>SOAP-ENC</code> encoding style.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class ParameterSerializer implements Serializer, Deserializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      Parameter param = (Parameter)src;
      Class type = param.getType();
      String name = param.getName();
      Object value = param.getValue();
  
      if (value == null && !type.isArray())
      {
        SoapEncUtils.generateNullStructure(inScopeEncStyle, type, name,
                                           sink, nsStack, xjmr);
      }
      else
      {
        String declEncStyle = param.getEncodingStyleURI();
        String actualEncStyle = declEncStyle != null
                                ? declEncStyle
                                : inScopeEncStyle;
        Serializer s = xjmr.querySerializer(type, actualEncStyle);
  
        s.marshall(inScopeEncStyle, type, value, name, sink, nsStack, xjmr);
      }
  
      nsStack.popScope();
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException
    {
      Element paramEl = (Element)src;
      String name = paramEl.getTagName();
      QName soapType = SoapEncUtils.getAttributeValue(paramEl,
        Constants.NS_URI_SCHEMA_XSI, Constants.ATTR_TYPE, "parameter", true);
      Bean bean = (SoapEncUtils.isNull(paramEl)
                   && !new QName(Constants.NS_URI_SOAP_ENC,
                                 "Array").equals(soapType)
                   ? new Bean(xjmr.queryJavaType(soapType, inScopeEncStyle),
                              null)
                   : xjmr.unmarshall(inScopeEncStyle, soapType, paramEl));
      Parameter parameter = new Parameter(name, bean.type,
                                          bean.value, null);
  
      return new Bean(Parameter.class, parameter);
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/encoding/soapenc/SoapEncUtils.java
  
  Index: SoapEncUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.encoding.soapenc;
  
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  
  /**
   * These static methods can be used to do much of the repetitive and
   * mechanical work that is required when generating structures using
   * the <code>SOAP-ENC</code> encoding style.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class SoapEncUtils
  {
    public static void generateNullStructure(String inScopeEncStyle,
                                             Class javaType, Object context,
                                             Writer sink, NSStack nsStack,
                                             XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      generateStructureHeader(inScopeEncStyle, javaType, context, sink,
                              nsStack, xjmr, null, null, true);
    }
  
    public static void generateNullArray(String inScopeEncStyle,
                                         Class javaType, Object context,
                                         Writer sink, NSStack nsStack,
                                         XMLJavaMappingRegistry xjmr,
                                         QName arrayElementType,
                                         String arrayLengthStr)
      throws IllegalArgumentException, IOException
    {
      generateStructureHeader(inScopeEncStyle, javaType, context, sink,
                              nsStack, xjmr, arrayElementType, arrayLengthStr,
                              true);
    }
  
    public static void generateArrayHeader(String inScopeEncStyle,
                                           Class javaType, Object context,
                                           Writer sink, NSStack nsStack,
                                           XMLJavaMappingRegistry xjmr,
                                           QName arrayElementType,
                                           String arrayLengthStr)
      throws IllegalArgumentException, IOException
    {
      generateStructureHeader(inScopeEncStyle, javaType, context, sink,
                              nsStack, xjmr, arrayElementType, arrayLengthStr,
                              false);
    }
  
    public static void generateStructureHeader(String inScopeEncStyle,
                                               Class javaType, Object context,
                                               Writer sink, NSStack nsStack,
                                               XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      generateStructureHeader(inScopeEncStyle, javaType, context, sink,
                              nsStack, xjmr, null, null, false);
    }
  
    private static void generateStructureHeader(String inScopeEncStyle,
                                                Class javaType, Object context,
                                                Writer sink, NSStack nsStack,
                                                XMLJavaMappingRegistry xjmr,
                                                QName arrayElementType,
                                                String arrayLengthStr,
                                                boolean isNull)
      throws IllegalArgumentException, IOException
    {
      QName elementType = xjmr.queryElementType(javaType,
                                                Constants.NS_URI_SOAP_ENC);
  
      sink.write('<' + context.toString());
  
      // Get prefixes for the needed namespaces.
      String xsiNSPrefix = nsStack.getPrefixFromURI(
        Constants.NS_URI_SCHEMA_XSI, sink);
      String elementTypeNSPrefix = nsStack.getPrefixFromURI(
        elementType.getNamespaceURI(), sink);
  
      sink.write(' ' + xsiNSPrefix + ':' + Constants.ATTR_TYPE + "=\"" +
                 elementTypeNSPrefix + ':' +
                 elementType.getLocalPart() + '\"');
  
      if (inScopeEncStyle == null
          || !inScopeEncStyle.equals(Constants.NS_URI_SOAP_ENC))
      {
        // Determine the prefix associated with the NS_URI_SOAP_ENV
        // namespace URI.
        String soapEnvNSPrefix = nsStack.getPrefixFromURI(
          Constants.NS_URI_SOAP_ENV, sink);
  
        sink.write(' ' + soapEnvNSPrefix + ':' +
                   Constants.ATTR_ENCODING_STYLE + "=\"" +
                   Constants.NS_URI_SOAP_ENC + '\"');
      }
  
      if (arrayElementType != null)
      {
        String arrayElementTypeNSPrefix = nsStack.getPrefixFromURI(
          arrayElementType.getNamespaceURI(), sink);
        String arrayTypeValue = arrayElementTypeNSPrefix + ':' +
                                arrayElementType.getLocalPart() +
                                '[' + arrayLengthStr + ']';
        String soapEncNSPrefix = nsStack.getPrefixFromURI(
          Constants.NS_URI_SOAP_ENC, sink);
  
        sink.write(' ' + soapEncNSPrefix + ':' +
                   Constants.ATTR_ARRAY_TYPE + "=\"" + arrayTypeValue + '\"');
      }
  
      if (isNull)
      {
        sink.write(' ' + xsiNSPrefix + ':' + Constants.ATTR_NULL + "=\"" +
                   Constants.ATTRVAL_TRUE + "\"/");
      }
  
      sink.write('>');
    }
  
    public static boolean isNull(Element element)
    {
      String nullValue = element.getAttributeNS(Constants.NS_URI_SCHEMA_XSI,
                                                Constants.ATTR_NULL);
  
      return nullValue != null
             && nullValue.equals(Constants.ATTRVAL_TRUE);
    }
  
    public static QName getAttributeValue(Element el,
                                          String attrNameNamespaceURI,
                                          String attrNameLocalPart,
                                          String elDesc,
                                          boolean isRequired)
      throws IllegalArgumentException
    {
      String attrValue = el.getAttributeNS(attrNameNamespaceURI,
                                           attrNameLocalPart);
  
      if (attrValue != null)
      {
        int index = attrValue.indexOf(':');
  
        if (index != -1)
        {
          String attrValuePrefix       = attrValue.substring(0, index);
          String attrValueLocalPart    = attrValue.substring(index + 1);
          String attrValueNamespaceURI =
            DOMUtils.getNamespaceURIFromPrefix(el, attrValuePrefix);
  
          if (attrValueNamespaceURI != null)
          {
            return new QName(attrValueNamespaceURI, attrValueLocalPart);
          }
          else
          {
            throw new IllegalArgumentException("Unable to resolve namespace " +
                                               "URI for '" + attrValuePrefix +
                                               "'.");
          }
        }
        else
        {
          throw new IllegalArgumentException("The value of the '" +
                                             attrNameNamespaceURI + ':' +
                                             attrNameLocalPart +
                                             "' attribute must be " +
                                             "namespace-qualified.");
        }
      }
      else if (isRequired)
      {
        throw new IllegalArgumentException("The '" +
                                           attrNameNamespaceURI + ':' +
                                           attrNameLocalPart +
                                           "' attribute must be " +
                                           "specified for every " +
                                           elDesc + '.');
      }
      else
      {
        return null;
      }
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/encoding/xmi/XMIParameterSerializer.java
  
  Index: XMIParameterSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.encoding.xmi;
  
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.rpc.*;
  
  /**
   * A <code>ParameterSerializer</code> is used to serialize and deserialize
   * parameters using the <code>XMI</code> encoding style.
   *
   * @author Francisco Curbera (curbera@us.ibm.com)
   */
  public class XMIParameterSerializer implements Serializer, Deserializer
  {
    XMIDeserializer xmideserializer = new XMIDeserializer();
    
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      Parameter param = (Parameter)src;
      Class type = param.getType();
      String name = param.getName();
      Object value = param.getValue();
      
      xjmr.marshall(Constants.NS_URI_XMI_ENC, type, value, name, sink, nsStack);
  
      nsStack.popScope();
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException
    {
  
      Element paramEl = (Element)src;
      String name = paramEl.getTagName();
  
      // special case for Strings
      if (name.equals("java.lang.String"))
      {
        String st = paramEl.getAttribute("value");
  
        if (st == null)
          throw new IllegalArgumentException("Unable to unmarshall XMI string.");
  
        Bean bean = new Bean(java.lang.String.class, new String(st));
        Parameter parameter = new Parameter(name, bean.type, bean.value, null);
  
        return new Bean(Parameter.class, parameter);
      }
      // special case for nulls
      else if (name.equals("null"))
      {
        String typeName = paramEl.getAttribute("type");
  
        try
        {
          Bean bean = new Bean(Class.forName(typeName), null);
          Parameter parameter = new Parameter(name, bean.type, bean.value, null);
  
          return new Bean(Parameter.class, parameter);
        }
        catch (Exception e)
        {
          throw new IllegalArgumentException("Unable to unmarshall XMI null.");
        }
      }
  
      Bean bean = xmideserializer.unmarshall(Constants.NS_URI_XMI_ENC, elementType, paramEl, xjmr);
      Parameter parameter = new Parameter(name, bean.type, bean.value, null);    
  
      return new Bean(Parameter.class, parameter);
  
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/rpc/Call.java
  
  Index: Call.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.rpc;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import java.lang.reflect.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.util.IOUtils;
  import org.apache.soap.*;
  import org.apache.soap.encoding.*;
  import org.apache.soap.transport.*;
  import org.apache.soap.transport.http.*;
  import org.apache.soap.server.*;
  
  /**
   * A <code>Call</code> object represents an <em>RPC</em> call. Both the
   * client and the server use <code>Call</code> objects to invoke the
   * method.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class Call extends RPCMessage
  {
    private XMLParserLiaison    xpl = new XercesParserLiaison();
    private SOAPMappingRegistry smr = new SOAPMappingRegistry();
    private SOAPTransport       st  = new SOAPHTTPConnection();
  
    public Call()
    {
      this(null, null, null, null, null);
    }
  
    public Call(String targetObjectURI, String methodName, Vector params,
                Header header, String encodingStyleURI)
    {
      super(targetObjectURI, methodName, params, header, encodingStyleURI);
    }
  
    public void setSOAPMappingRegistry(SOAPMappingRegistry smr)
    {
      this.smr = smr;
    }
  
    public SOAPMappingRegistry getSOAPMappingRegistry()
    {
      return smr;
    }
  
    public void setSOAPTransport(SOAPTransport st)
    {
      this.st = st;
    }
     
    public SOAPTransport getSOAPTransport()
    {
      return st;
    }
  
    public Envelope buildEnvelope()
    {
      return super.buildEnvelope(false);
    }
  
    public static Call extractFromEnvelope(Envelope env, ServiceManager svcMgr)
      throws IllegalArgumentException
    {
      return (Call)RPCMessage.extractFromEnvelope(env, svcMgr, false, null);
    }
  
    /**
     * Invoke this call at the specified URL. Valid only on the client side.
     */
    public Response invoke(URL url, String SOAPActionURI) throws SOAPException
    {
      if (SOAPActionURI == null)
      {
        SOAPActionURI = "";
      }
  
      try
      {
        // Build an envelope containing the call.
        Envelope callEnv = buildEnvelope();
  
        // Post the call envelope.
        st.send(url, SOAPActionURI, null, callEnv, smr);
  
        // Get the input stream to read the response envelope from.
        BufferedReader in = st.receive();
  
        /*
          Must pre-read the incoming stream to avoid the parser drying up
          the stream in case a parsing error occurs.
        */
        String payloadStr = IOUtils.getStringFromReader(in);
  
        // Parse the incoming response stream.
        Document respDoc = xpl.read("- SOAP HTTP RPC Response Envelope -",
                                    new StringReader(payloadStr));
        Element payload = null;
  
        if (respDoc != null)
        {
          payload = respDoc.getDocumentElement();
        }
        else
        {
          throw new SOAPException(Constants.FAULT_CODE_PROTOCOL,
                                  payloadStr);
        }
  
        // Unmarshall the response envelope.
        Envelope respEnv = Envelope.unmarshall(payload);
  
        // Extract the response from the response envelope.
        Response resp = Response.extractFromEnvelope(respEnv, smr);
  
        return resp;
      }
      catch (IllegalArgumentException e)
      {
        throw new SOAPException(Constants.FAULT_CODE_CLIENT, e.getMessage(), e);
      }
      catch (IOException e)
      {
        throw new SOAPException(Constants.FAULT_CODE_PROTOCOL,
                                e.getMessage(), e);
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/rpc/Parameter.java
  
  Index: Parameter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.rpc;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.*;
  
  /**
   * A <code>Parameter</code> represents an argument to an <em>RPC</em>
   * call. <code>Parameter</code> objects are used by both the client
   * and the server.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class Parameter
  {
    private String name             = null;
    private Class  type             = null;
    private Object value            = null;
    private String encodingStyleURI = null;
  
    public Parameter(String name,
                     Class  type,
                     Object value,
                     String encodingStyleURI)
    {
      this.name = name;
      this.type = type;
      this.value = value;
      this.encodingStyleURI = encodingStyleURI;
    }
  
    public void setName(String name)
    {
      this.name = name;
    }
  
    public String getName()
    {
      return name;
    }
  
    public void setType(Class type)
    {
      this.type = type;
    }
  
    public Class getType()
    {
      return type;
    }
  
    public void setValue(Object value)
    {
      this.value = value;
    }
  
    public Object getValue()
    {
      return value;
    }
  
    public void setEncodingStyleURI(String encodingStyleURI)
    {
      this.encodingStyleURI = encodingStyleURI;
    }
  
    public String getEncodingStyleURI()
    {
      return encodingStyleURI;
    }
  
    public String toString()
    {
      return "[name=" + name + "] " +
             "[type=" + type + "] " +
             "[value=" + value + "] " +
             "[encodingStyleURI=" + encodingStyleURI + "]";
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/rpc/RPCConstants.java
  
  Index: RPCConstants.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.rpc;
  
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  
  /**
   * <em>SOAP</em> constants used for <code>RPC</code>.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class RPCConstants
  {
    // Element names.
    public static String ELEM_PARAMETER = "Parameter";
    public static String ELEM_RETURN = "return";
  
    // Qualified element names.
    public static QName  Q_ELEM_PARAMETER =
      new QName(Constants.NS_URI_SOAP_ENV, ELEM_PARAMETER);
  
    // Other constants.
    public static String RESPONSE_SUFFIX = "Response";
  
    // IBM implementation defined fault codes.
    public static String FAULT_CODE_SERVER_BAD_TARGET_OBJECT_URI =
      Constants.FAULT_CODE_SERVER + ".BadTargetObjectURI";
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/rpc/RPCMessage.java
  
  Index: RPCMessage.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.rpc;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.*;
  import org.apache.soap.server.*;
  
  /**
   * An <code>RPCMessage</code> is the base class that <code>Call</code> and
   * <code>Response</code> extend from. Any work that is common to both
   * <code>Call</code> and <code>Response</code> is done here.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class RPCMessage implements Serializer
  {
    protected String targetObjectURI;
    protected String methodName;
    protected Vector params;
    protected Header header;
    protected String encodingStyleURI;
  
    protected RPCMessage(String targetObjectURI, String methodName,
                         Vector params, Header header, String encodingStyleURI)
    {
      this.targetObjectURI  = targetObjectURI;
      this.methodName       = methodName;
      this.params           = params;
      this.header           = header;
      this.encodingStyleURI = encodingStyleURI;
    }
  
    public void setTargetObjectURI(String targetObjectURI)
    {
      this.targetObjectURI = targetObjectURI;
    }
  
    public String getTargetObjectURI()
    {
      return targetObjectURI;
    }
  
    public void setMethodName(String methodName)
    {
      this.methodName = methodName;
    }
  
    public String getMethodName()
    {
      return methodName;
    }
  
    public void setParams(Vector params)
    {
      this.params = params;
    }
  
    public Vector getParams()
    {
      return params;
    }
  
    public void setHeader(Header header)
    {
      this.header = header;
    }
  
    public Header getHeader()
    {
      return header;
    }
  
    public void setEncodingStyleURI(String encodingStyleURI)
    {
      this.encodingStyleURI = encodingStyleURI;
    }
  
    public String getEncodingStyleURI()
    {
      return encodingStyleURI;
    }
  
    protected Envelope buildEnvelope(boolean isResponse)
    {
      // Construct a new envelope for this message.
      Envelope env = new Envelope();
      Body body = new Body();
      Vector bodyEntries = new Vector();
  
      bodyEntries.addElement(new Bean((isResponse ? Response.class : Call.class),
                                      this));
      body.setBodyEntries(bodyEntries);
      env.setBody(body);
      env.setHeader(header);
  
      return env;
    }
  
    protected static RPCMessage extractFromEnvelope(Envelope env,
                                                    ServiceManager svcMgr,
                                                    boolean isResponse,
                                                    SOAPMappingRegistry respSMR)
      throws IllegalArgumentException
    {
      Body body = env.getBody();
      Vector bodyEntries = body.getBodyEntries();
      RPCMessage msg = null;
  
      // Unmarshall the message, which is the first body entry.
      if (bodyEntries.size() > 0)
      {
        Element msgEl = (Element)bodyEntries.elementAt(0);
        Class toClass = isResponse ? Response.class : Call.class;
        String declEnvEncStyle = env.getAttribute(new QName(
          Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE));
        String declBodyEncStyle = body.getAttribute(new QName(
          Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE));
        String actualEncStyle = declBodyEncStyle != null
                                ? declBodyEncStyle
                                : declEnvEncStyle;
  
        msg = RPCMessage.unmarshall(actualEncStyle, msgEl, toClass, svcMgr,
                                    respSMR);
        msg.setHeader(env.getHeader());
  
        return msg;
      }
      else
      {
        throw new IllegalArgumentException("An '" + Constants.Q_ELEM_BODY +
                                           "' element must contain a " +
                                           "child element.");
      }
    }
  
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException
    {
      nsStack.pushScope();
  
      RPCMessage msg               = (RPCMessage)src;
      boolean    isResponse        = (javaType == Response.class);
      String     targetObjectURI   = Utils.cleanString(msg.getTargetObjectURI());
      String     methodName        = msg.getMethodName();
      Vector     params            = msg.getParams();
      String     suffix            = isResponse
                                     ? RPCConstants.RESPONSE_SUFFIX
                                     : "";
      String     declMsgEncStyle   = msg.getEncodingStyleURI();
      String     actualMsgEncStyle = declMsgEncStyle != null
                                     ? declMsgEncStyle
                                     : inScopeEncStyle;
  
      // If this message is a response, check for a fault.
      if (isResponse)
      {
        Response resp = (Response)msg;
  
        if (!resp.generatedFault())
        {
          // Get the prefix for the targetObjectURI.
          StringWriter nsDeclSW = new StringWriter();
          String targetObjectNSPrefix = nsStack.getPrefixFromURI(
            targetObjectURI, nsDeclSW);
  
          sink.write('<' + targetObjectNSPrefix + ':' +
                     methodName + suffix + nsDeclSW);
  
          // Determine the prefix associated with the NS_URI_SOAP_ENV
          // namespace URI.
          String soapEnvNSPrefix = nsStack.getPrefixFromURI(
            Constants.NS_URI_SOAP_ENV, sink);
  
          if (declMsgEncStyle != null
              && !declMsgEncStyle.equals(inScopeEncStyle))
          {
            sink.write(' ' + soapEnvNSPrefix + ':' +
                       Constants.ATTR_ENCODING_STYLE + "=\"" +
                       declMsgEncStyle + '\"');
          }
  
          sink.write('>' + StringUtils.lineSeparator);
  
          // Get the returnValue.
          Parameter ret = resp.getReturnValue();
  
          if (ret != null)
          {
            String declParamEncStyle = ret.getEncodingStyleURI();
            String actualParamEncStyle = declParamEncStyle != null
                                         ? declParamEncStyle
                                         : actualMsgEncStyle;
            Serializer ser = xjmr.querySerializer(Parameter.class,
                                                  actualParamEncStyle);
  
            ser.marshall(actualMsgEncStyle, Parameter.class, ret, null,
                         sink, nsStack, xjmr);
  
            sink.write(StringUtils.lineSeparator);
          }
  
          serializeParams(params, actualMsgEncStyle, sink, nsStack, xjmr);
  
          sink.write("</" + targetObjectNSPrefix + ':' +
                     methodName + suffix + '>' +
                     StringUtils.lineSeparator);
        }
        else
        {
          // Get the fault information.
          Fault fault = resp.getFault();
  
          fault.marshall(actualMsgEncStyle, sink, nsStack, xjmr);
        }
      }
      else
      {
        // Get the prefix for the targetObjectURI.
        StringWriter nsDeclSW = new StringWriter();
        String targetObjectNSPrefix = nsStack.getPrefixFromURI(targetObjectURI,
                                                               nsDeclSW);
  
        sink.write('<' + targetObjectNSPrefix + ':' +
                   methodName + suffix + nsDeclSW);
  
        // Determine the prefix associated with the NS_URI_SOAP_ENV
        // namespace URI.
        String soapEnvNSPrefix = nsStack.getPrefixFromURI(
          Constants.NS_URI_SOAP_ENV, sink);
  
        if (declMsgEncStyle != null
            && !declMsgEncStyle.equals(inScopeEncStyle))
        {
          sink.write(' ' + soapEnvNSPrefix + ':' +
                     Constants.ATTR_ENCODING_STYLE + "=\"" +
                     declMsgEncStyle + '\"');
        }
  
        sink.write('>' + StringUtils.lineSeparator);
  
        serializeParams(params, actualMsgEncStyle, sink, nsStack, xjmr);
  
        sink.write("</" + targetObjectNSPrefix + ':' +
                   methodName + suffix + '>' +
                   StringUtils.lineSeparator);
      }
  
      nsStack.popScope();
    }
  
    private void serializeParams(Vector params, String inScopeEncStyle,
                                 Writer sink, NSStack nsStack,
                                 XMLJavaMappingRegistry xjmr)
      throws IOException
    {
      // If parameters exist, serialize them.
      if (params != null)
      {
        int size = params.size();
  
        for (int i = 0; i < size; i++)
        {
          Parameter param = (Parameter)params.elementAt(i);
          String declParamEncStyle = param.getEncodingStyleURI();
          String actualParamEncStyle = declParamEncStyle != null
                                       ? declParamEncStyle
                                       : inScopeEncStyle;
          Serializer ser = xjmr.querySerializer(Parameter.class,
                                                actualParamEncStyle);
  
          ser.marshall(inScopeEncStyle, Parameter.class, param, null, sink,
                       nsStack, xjmr);
  
          sink.write(StringUtils.lineSeparator);
        }
      }
    }
  
    public static RPCMessage unmarshall(String inScopeEncStyle, Node src,
                                        Class toClass, ServiceManager svcMgr,
                                        SOAPMappingRegistry respSMR)
      throws IllegalArgumentException
    {
      SOAPMappingRegistry smr       = null;
      Element   root                = (Element)src;
      boolean   isResponse          = (toClass == Response.class);
      String    targetObjectURI     = null;
      String    methodName          = null;
      Parameter returnValue         = null;
      Fault     fault               = null;
      Vector    params              = null;
      String    declMsgEncStyle     = root.getAttributeNS(
        Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
      String    actualMsgEncStyle   = declMsgEncStyle != null
                                      ? declMsgEncStyle
                                      : inScopeEncStyle;
  
      // Is it a fault?
      if (isResponse && Constants.Q_ELEM_FAULT.matches(root))
      {
        fault = Fault.unmarshall(actualMsgEncStyle, root, respSMR);
      }
      else
      {
        // Must be a method call or a faultless response.
        String tagName = root.getLocalName();
  
        targetObjectURI = root.getNamespaceURI();
  
        // Determine the XML serialization registry based on whether
        // I'm on the server side or on the client side.
        if (!isResponse)
        {
          // I'm on the server side unmarshalling a call.
  	DeploymentDescriptor dd = null;
  	try
          {
  	  dd = svcMgr.query(targetObjectURI);
            smr = DeploymentDescriptor.buildSOAPMappingRegistry(dd);
  	} 
          catch (SOAPException e)
          {
            throw new IllegalArgumentException("Unable to resolve " +
                                               "targetObjectURI '" +
                                               targetObjectURI + "'.");
          }
        }
        else
        {
          // I'm on the client unmarshalling a response.
          smr = respSMR;
        }
  
        /*
          Sanity check: the name of the method element should be the
          methodName for a call and should be methodName+"Response"
          for a response. Note: currently no way to know the methodName
          other than from the tag name.
        */
        if (isResponse)
        {
          if (tagName.endsWith(RPCConstants.RESPONSE_SUFFIX))
          {
            // Strip "Response" from end of tagName to derive methodName.
            methodName = tagName.substring(0, tagName.length() - 8);
          }
          else
          {
            throw new IllegalArgumentException("Element name '" +
                                               tagName +
                                               "' must end with '" +
                                               RPCConstants.RESPONSE_SUFFIX +
                                               "'.");
          }
        }
        else
        {
          methodName = tagName;
        }
  
        Element tempEl = DOMUtils.getFirstChildElement(root);
  
        // Get the return value.
        if (isResponse && tempEl != null)
        {
          String declParamEncStyle = tempEl.getAttributeNS(
            Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
          String actualParamEncStyle = declParamEncStyle != null
                                       ? declParamEncStyle
                                       : actualMsgEncStyle;
          Bean returnBean = smr.unmarshall(actualParamEncStyle,
                                           RPCConstants.Q_ELEM_PARAMETER,
                                           tempEl);
  
          returnValue = (Parameter)returnBean.value;
  
          if (declParamEncStyle != null)
          {
            returnValue.setEncodingStyleURI(declParamEncStyle);
          }
  
          tempEl = DOMUtils.getNextSiblingElement(tempEl);
        }
  
        // Get the parameters.
        if (tempEl != null)
        {
          for (params = new Vector();
               tempEl != null;
               tempEl = DOMUtils.getNextSiblingElement(tempEl))
          {
            String declParamEncStyle = tempEl.getAttributeNS(
              Constants.NS_URI_SOAP_ENV, Constants.ATTR_ENCODING_STYLE);
            String actualParamEncStyle = declParamEncStyle != null
                                         ? declParamEncStyle
                                         : actualMsgEncStyle;
            Bean paramBean = smr.unmarshall(actualParamEncStyle,
                                            RPCConstants.Q_ELEM_PARAMETER,
                                            tempEl);
            Parameter param = (Parameter)paramBean.value;
  
            if (declParamEncStyle != null)
            {
              param.setEncodingStyleURI(declParamEncStyle);
            }
  
            params.addElement(param);
          }
        }
      }
  
      RPCMessage msg = isResponse
                       ? (fault == null
                          ? (RPCMessage)new Response(targetObjectURI, methodName,
                                                     returnValue, params, null,
                                                     declMsgEncStyle)
                          : (RPCMessage)new Response(targetObjectURI, methodName,
                                                     fault, params, null,
                                                     declMsgEncStyle))
                       : (RPCMessage)new Call(targetObjectURI, methodName,
                                              params, null, declMsgEncStyle);
  
      if (msg instanceof Call)
      {
        ((Call)msg).setSOAPMappingRegistry(smr);
      }
  
      return msg;
    }
  
    public String toString()
    {
      StringWriter sw = new StringWriter();
      PrintWriter pw = new PrintWriter(sw);
      boolean isResponse = this instanceof Response;
  
      pw.print("[Header=" + header + "] " +
               "[methodName=" + methodName + "] " +
               "[targetObjectURI=" + targetObjectURI + "] " +
               "[encodingStyleURI=" + encodingStyleURI + "] ");
  
      if (isResponse)
      {
        Response res = (Response)this;
  
        if (res.generatedFault())
        {
          pw.print("[fault=" + res.getFault() + "] ");
        }
        else
        {
          pw.println("[return=" + res.getReturnValue() + "] ");
        }
      }
  
      pw.print("[Params={");
  
      if (params != null)
      {
        for (int i = 0; i < params.size(); i++)
        {
          if (i > 0)
          {
            pw.print(", ");
          }
  
          pw.print("[" + params.elementAt(i) + "]");
        }
      }
  
      pw.print("}]");
  
      return sw.toString();
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/rpc/Response.java
  
  Index: Response.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.rpc;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.*;
  
  /**
   * A <code>Response</code> object represents an <em>RPC</em> response. Both
   * the client and the server use <code>Response</code> objects to represent
   * the result of a method invocation.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class Response extends RPCMessage
  {
    private Parameter returnValue;
    private Fault     fault;
  
    /**
     * Use this constructor when everything went well.
     */
    public Response(String targetObjectURI, String methodName,
                    Parameter returnValue, Vector params, Header header,
                    String encodingStyleURI)
    {
      super(targetObjectURI, methodName, params, header, encodingStyleURI);
  
      this.returnValue = returnValue;
    }
  
    /**
     * Use this constructor when things didn't go so well.
     */
    public Response(String targetObjectURI, String methodName,
                    Fault fault, Vector params, Header header,
                    String encodingStyleURI)
    {
      super(targetObjectURI, methodName, params, header, encodingStyleURI);
  
      this.fault = fault;
    }
  
    public void setReturnValue(Parameter returnValue)
    {
      this.returnValue = returnValue;
    }
  
    public Parameter getReturnValue()
    {
      return returnValue;
    }
  
    public void setFault(Fault fault)
    {
      this.fault = fault;
    }
  
    public Fault getFault()
    {
      return fault;
    }
  
    public boolean generatedFault()
    {
      return fault != null;
    }
  
    public Envelope buildEnvelope()
    {
      return super.buildEnvelope(true);
    }
  
    public static Response extractFromEnvelope(Envelope env,
                                               SOAPMappingRegistry smr)
      throws IllegalArgumentException
    {
      return (Response)RPCMessage.extractFromEnvelope(env, null, true, smr);
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/DeploymentDescriptor.java
  
  Index: DeploymentDescriptor.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.server;
  
  import java.util.*;
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.util.DOMUtils;
  import org.apache.soap.Constants;
  import org.apache.soap.encoding.*;
  
  /**
   * This class represents the deployment information about a SOAP service.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class DeploymentDescriptor implements Serializable {
    // scopes for the lifecycles of the provider class
    public static final int SCOPE_PAGE = 0;
    public static final int SCOPE_REQUEST = 1;
    public static final int SCOPE_SESSION = 2;
    public static final int SCOPE_APPLICATION = 3;
  
    // types of providers
    public static final byte PROVIDER_JAVA = (byte) 0;
    public static final byte PROVIDER_SCRIPT_FILE = (byte) 1;
    public static final byte PROVIDER_SCRIPT_STRING = (byte) 2;
  
    String id;
    int scope;
    byte providerType = -1;
    String providerClass;
    boolean isStatic;
    String scriptFilenameOrString;
    String scriptLanguage;
    String[] methods;
    TypeMapping[] mappings;
    transient SOAPMappingRegistry cachedSMR;
   
    /**
     * Constructor.
     *
     * @param id the name of the service. Should be of valid URI syntax.
     */
    public DeploymentDescriptor () {
    }
  
    /**
     * ID of this service.
     */
    
    public void setID (String id) {
      this.id = id;
    }
  
    public String getID () {
      return id;
    }
  
    /**
     * Lifecyle of the object providing the service. 
     */
    public void setScope (int scope) {
      this.scope = scope;
    }
  
    public int getScope () {
      return scope;
    }
  
    /**
     * Methods provided by the service.
     */
    public void setMethods (String[] methods) {
      this.methods = methods;
    }
  
    public String[] getMethods () {
      return methods;
    }
  
    /**
     * Type of provider. 
     */
    public void setProviderType (byte providerType) {
      this.providerType = providerType;
    }
  
    public byte getProviderType () {
      return providerType;
    }
  
    /**
     * For Java providers, the class providing the service.
     */
    public void setProviderClass (String providerClass) {
      this.providerClass = providerClass;
    }
  
    public String getProviderClass () {
      return providerClass;
    }
  
    /**
     * For Java providers, is it static or not.
     */
    public void setIsStatic (boolean isStatic) {
      this.isStatic = isStatic;
    }
  
    public boolean getIsStatic () {
      return isStatic;
    }
  
    public void setScriptLanguage (String scriptLanguage) {
      this.scriptLanguage = scriptLanguage;
    }
  
    public String getScriptLanguage () {
      return scriptLanguage;
    }
  
    public void setScriptFilenameOrString (String scriptFilenameOrString) {
      this.scriptFilenameOrString = scriptFilenameOrString;
    }
  
    public String getScriptFilenameOrString () {
      return scriptFilenameOrString;
    }
  
    /**
     * Type mappings between XML types of certain encodings and
     * Java types. 
     *
     * @param map the structure containing the mapping info
     */
    public void setMappings (TypeMapping[] mappings) {
      this.mappings = mappings;
    }
  
    /**
     * Return the registered mappings.
     */
    public TypeMapping[] getMappings () {
      return mappings;
    }
  
    /**
     * Cache the SOAP serialization registry for this descriptor; used only
     * by me.
     */
    private void setCachedSMR (SOAPMappingRegistry cachedSMR) {
      this.cachedSMR = cachedSMR;
    }
  
    private SOAPMappingRegistry getCachedSMR () {
      return cachedSMR;
    }
  
    /**
     * Write out the deployment descriptor according to the 
     * the deployment descriptor DTD.
     */
    public void toXML (Writer pr) {
      PrintWriter pw = new PrintWriter (pr);
      
      pw.println ("<isd:service xmlns:isd=\"" +
  		Constants.NS_URI_IBM_DEPLOYMENT + "\" id=\"" + id + "\">");
  
      byte pt = providerType;
      String[] scopes = {"Page", "Request", "Session", "Application"};
      pw.print ("  <isd:provider type=\"" + 
  	      (pt == DeploymentDescriptor.PROVIDER_JAVA ? "java" : "script") +
  	      "\" scope=\"" + scopes[scope] + "\" methods=\"");
      for (int i = 0; i < methods.length; i++) {
        pw.print (methods[i]);
        if (i < methods.length-1) {
  	pw.print (" ");
        }
      }
      pw.println ("\">");
      if (pt == DeploymentDescriptor.PROVIDER_JAVA) {
        pw.println ("    <isd:java class=\"" + providerClass +
  		  "\" static=\"" + (isStatic ? "true" : "false") + "\"/>");
      } else {
        pw.print ("    <isd:script language=\"" + scriptLanguage);
        if (pt == DeploymentDescriptor.PROVIDER_SCRIPT_FILE) {
  	pw.println (" source=\"" + scriptFilenameOrString + "\"/>");
        } else {
  	pw.println ("\">");
  	pw.println ("      <![CDATA[");
  	pw.println (scriptFilenameOrString);
  	pw.println ("      ]]>");
  	pw.println ("    </isd:script>");
        }
      }
      pw.println ("  </isd:provider>");
  
      if (mappings != null) {
        pw.println ("  <isd:mappings>");
        for (int i = 0; i < mappings.length; i++) {
  	TypeMapping tm = mappings[i];
  	pw.print ("    <isd:map encodingStyle=\"" + tm.encodingStyle +
  		  "\" xmlns:x=\"" + tm.elementType.getNamespaceURI () +
  		  "\" qname=\"x:" + tm.elementType.getLocalPart () +
  		  "\" javaType=\"" + tm.javaType + "\"");
  	if (tm.xml2JavaClassName != null) {
  	  pw.print (" xml2JavaClassName=\"" + tm.xml2JavaClassName + "\"");
  	}
  	if (tm.java2XMLClassName != null) {
  	  pw.print (" java2XMLClassName=\"" + tm.java2XMLClassName + "\"");
  	}
  	pw.println ("/>");
        }
        pw.println ("  </isd:mappings>");
      }
  
      pw.println ("</isd:service>");
      pw.flush ();
    }
  
    /**
     * Build a deployment descriptor from a document corresponding to
     * the deployment descriptor DTD.
     */
    public static DeploymentDescriptor fromXML (Element root) {
      if ((root == null) ||
  	!root.getNamespaceURI().equals (Constants.NS_URI_IBM_DEPLOYMENT) ||
  	!root.getLocalName().equals ("service")) {
        throw new IllegalArgumentException ("root is null or document element " +
  					  "is not {" +
  					  Constants.NS_URI_IBM_DEPLOYMENT +
  					  "}service");
      }
  
      DeploymentDescriptor dd = new DeploymentDescriptor ();
      NodeList nl;
      Element e;
      
      String id = DOMUtils.getAttribute (root, "id");
      if (id == null) {
        throw new IllegalArgumentException ("required 'id' attribute " +
  					  "missing in deployment descriptor");
      }
      dd.setID (id);
  
      nl = root.getElementsByTagNameNS (Constants.NS_URI_IBM_DEPLOYMENT,
  				      "provider");
      if ((nl == null) || nl.getLength () != 1) {
        throw new IllegalArgumentException ("exactly one 'provider' element " +
  					  "missing in deployment descriptor");
      }
      e = (Element) nl.item (0);
      String typeStr = DOMUtils.getAttribute (e, "type");
      String scopeStr = DOMUtils.getAttribute (e, "scope");
      String methodsStr = DOMUtils.getAttribute (e, "methods");
      if ((typeStr == null) ||
  	(!typeStr.equals ("java") && !typeStr.equals ("script")) ||
  	(scopeStr == null) ||
  	(!scopeStr.equals ("Page") && !scopeStr.equals ("Request") &&
  	 !scopeStr.equals ("Session") && !scopeStr.equals ("Application")) ||
  	(methodsStr == null) || methodsStr.equals ("")) {
        throw new IllegalArgumentException ("invalid value for type or scope " +
  					  "or methods attribute in provider " +
  					  "element of deployment descriptor");
      }
      
      int scope = -1;
      String[] methods;
  
      if (typeStr.equals ("java")) {
        dd.setProviderType (DeploymentDescriptor.PROVIDER_JAVA);
        nl = e.getElementsByTagNameNS (Constants.NS_URI_IBM_DEPLOYMENT, "java");
        if ((nl == null) || nl.getLength () != 1) {
  	throw new IllegalArgumentException ("exactly one 'java' element " +
  					    "missing in deployment " +
  					    "descriptor");
        }
        e = (Element) nl.item (0);
        String className = DOMUtils.getAttribute (e, "class");
        if (className == null) {
  	throw new IllegalArgumentException ("<java> element requires " +
  					    "'class' attribute");
        }
        dd.setProviderClass (className);
        String isStatic = DOMUtils.getAttribute (e, "static");
        boolean isStaticBool = false;
        if (isStatic != null) {
  	if (isStatic.equals ("false")) {
  	  isStaticBool = false;
  	} else if (isStatic.equals ("true")) {
  	  isStaticBool = true;
  	} else {
  	  throw new IllegalArgumentException ("'static' attribute of " +
  					      "<java> element must be " +
  					      "true or false");
  	}
        }
        dd.setIsStatic (isStaticBool);
  
      } else {
        nl = e.getElementsByTagNameNS (Constants.NS_URI_IBM_DEPLOYMENT,
  				     "script");
        if ((nl == null) || nl.getLength () != 1) {
  	throw new IllegalArgumentException ("exactly one 'script' element " +
  					    "missing in deployment " +
  					    "descriptor");
        }
        e = (Element) nl.item (0);
        dd.setScriptLanguage (DOMUtils.getAttribute (e, "language"));
        String source = DOMUtils.getAttribute (e, "source");
        if (source != null) {
  	dd.setProviderType (DeploymentDescriptor.PROVIDER_SCRIPT_FILE);
  	dd.setScriptFilenameOrString (source);
        } else {
  	dd.setProviderType (DeploymentDescriptor.PROVIDER_SCRIPT_STRING);
  	dd.setScriptFilenameOrString (DOMUtils.getChildCharacterData (e));
        }
      }
  
      if (scopeStr.equals ("Page")) {
        scope = DeploymentDescriptor.SCOPE_PAGE;
      } else if (scopeStr.equals ("Request")) {
        scope = DeploymentDescriptor.SCOPE_REQUEST;
      } else if (scopeStr.equals ("Session")) {
        scope = DeploymentDescriptor.SCOPE_SESSION;
      } else { // scopeStr.equals ("Application")
        scope = DeploymentDescriptor.SCOPE_APPLICATION;
      }
      dd.setScope (scope);
  
      StringTokenizer st = new StringTokenizer (methodsStr);
      int nTokens = st.countTokens ();
      methods = new String[nTokens];
      for (int i = 0; i < nTokens; i++) {
        methods[i] = st.nextToken ();
      }
      dd.setMethods (methods);
      
      // read the type mappings
      nl = root.getElementsByTagNameNS (Constants.NS_URI_IBM_DEPLOYMENT,
  				      "mappings");
      if ((nl == null) || nl.getLength () > 1) {
        throw new IllegalArgumentException ("at most one 'mappings' element " +
  					  "allowed in deployment descriptor");
      }
      if (nl.getLength () == 1) {
        e = (Element) nl.item (0);
        nl = e.getElementsByTagNameNS (Constants.NS_URI_IBM_DEPLOYMENT, "map");
        int nmaps = nl.getLength ();
        if (nmaps > 0) {
  	TypeMapping[] tms = new TypeMapping[nmaps];
  	dd.setMappings (tms);
  	for (int i = 0; i < nmaps; i++) {
  	  e = (Element) nl.item (i); 
  	  String qnameQname = DOMUtils.getAttribute (e, "qname");
  	  int pos = qnameQname.indexOf (':');
  	  String prefix = qnameQname.substring (0, pos);
  	  String localPart = qnameQname.substring (pos+1);
  	  String nsURI = DOMUtils.getNamespaceURIFromPrefix (e, prefix);
  	  tms[i] = 
  	    new TypeMapping (DOMUtils.getAttribute (e, "encodingStyle"),
  			     new QName (nsURI, localPart),
  			     DOMUtils.getAttribute (e, "javaType"),
  			     DOMUtils.getAttribute (e, "java2XMLClassName"),
  			     DOMUtils.getAttribute (e, "java2XMLClassName"));
  	}
        }
      }
  
      return dd;
    }
  
    /**
     * What do u think this does?
     */
    public String toString () {
      StringBuffer methodsStrbuf = new StringBuffer ("[");
      for (int i = 0; i < methods.length; i++) {
        methodsStrbuf.append (methods[i]);
        if (i < methods.length-1) {
          methodsStrbuf.append (",");
        }
      }
      methodsStrbuf.append ("]");
      String header = "[DeploymentDescriptor id='" + id + "', " +
        "scope='" + scope + "', ";
      String body = null;
      if (providerType == PROVIDER_JAVA) {
        body = "class='" + providerClass + "', static='" + isStatic + "', ";
      } else if (providerType == PROVIDER_SCRIPT_FILE) {
        body = "source='" + scriptFilenameOrString + "', ";
        body += "language='" + scriptLanguage + "', ";
      } else {
        body = "script='" + scriptFilenameOrString + "', ";
        body += "language='" + scriptLanguage + "', ";
      }
      return header + body + "methods='" + methodsStrbuf + "', " +
        "mappings='" + mappings + "]";
    }
  
    /**
     * Utility to generate an XML serialization registry from all the
     * type mappings registered into a deployment descriptor.
     * 
     * @param dd the deployment descriptor
     * @return the xml serialization registry
     */
    public static SOAPMappingRegistry
    buildSOAPMappingRegistry (DeploymentDescriptor dd) {
      TypeMapping[] maps = dd.getMappings ();
      SOAPMappingRegistry smr = dd.getCachedSMR ();
      if (smr != null) {
        return smr;
      } else {
        smr = new SOAPMappingRegistry ();
      }
      if (maps != null) {
        for (int i = 0; i < maps.length; i++) {
  	TypeMapping tm = maps[i];
  	int step = 0;
  	try {
  	  step = 0;
  	  Class javaType = null;
  	  if (tm.javaType != null) {
  	    javaType = Class.forName (tm.javaType);
  	  }
  	  step = 1;
  	  Serializer s = null;
  	  if (tm.java2XMLClassName != null) {
  	    Class c = Class.forName (tm.java2XMLClassName);
  	    s = (Serializer) c.newInstance ();
  	  }
  	  step = 2;
  	  Deserializer d = null;
  	  if (tm.xml2JavaClassName != null) {
  	    Class c = Class.forName (tm.xml2JavaClassName);
  	    d = (Deserializer) c.newInstance ();
  	  }
  	  smr.mapTypes (tm.encodingStyle, tm.elementType, javaType, s, d);
  	} catch (Exception e2) {
  	  String m = "deployment error in SOAP service '" + dd.getID () + 
  	    "': ";
  	  if (step == 0) {
  	    m += "class name '" + tm.javaType + "' could not be resolved: ";
  	  } else if (step == 1) {
  	    m += "class name '" + tm.java2XMLClassName + "' could not be " +
  	      "resolved as a serializer: ";
  	  } else {
  	    m += "class name '" + tm.xml2JavaClassName + "' could not be " +
  	      "resolved as a deserializer: ";
  	  }
  	  throw new IllegalArgumentException (m + e2.getMessage ());
  	}
        }
      }
      dd.setCachedSMR (smr);
      return smr;
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/InvokeBSF.java
  
  Index: InvokeBSF.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.server;
  
  import org.apache.soap.util.Bean;
  import org.apache.soap.SOAPException;
  import org.apache.soap.Constants;
  import org.apache.soap.server.DeploymentDescriptor;
  import com.ibm.bsf.*;
  
  
  /**
   * This class provides a static method to invoke services implemented
   * via BSF. This code used to live in rpcrouter.jsp, but it was moved
   * here to keep rpcrouter.jsp independent of BSF (didn't want to prereq
   * BSF). The code in rpcrouter.jsp invokes these methods using reflection
   * to avoid being dependent on them ..
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class InvokeBSF {
  
    /**
     * This method is invoked to exec the script implementing the service into
     * the scripting engine so that later service calls can work.
     *
     * @param dd the deployment descriptor of the service
     * @param scriptStr the string containing function definitions to be exec'ed
     *
     * @exception SOAPException if something goes wrong
     */
    public static void init (DeploymentDescriptor dd, Object target,
  			   String scriptStr) throws SOAPException {
      try {
        BSFManager mgr = (BSFManager) target;
        mgr.exec (dd.getScriptLanguage (), "service script for '" + 
  		dd.getID () + "'", 0, 0, scriptStr);
      } catch (BSFException e) {
        throw new SOAPException (Constants.FAULT_CODE_SERVER,
  			       "BSF Error: " + e.getMessage (), e);
      }
    }
  
    /**
     * This method is invoked when a method is to be called.
     *
     * @param dd the deployment descriptor of the service
     * @param target the BSFManager object which is used to exec/call
     * @param methodName name of function in the script to call
     * @param args arguments to the function or null if none
     *
     * @return a Bean object containing the result
     *
     * @exception SOAPException if something goes wrong
     */
    public static Bean service (DeploymentDescriptor dd, Object target,
  			      String methodName, Object[] args) 
         throws SOAPException {
      try {
        BSFManager mgr = (BSFManager) target;
        BSFEngine eng = mgr.loadScriptingEngine (dd.getScriptLanguage ());
        Object result = eng.call (null, methodName, args);
        return new Bean ((result != null) ? result.getClass () : Object.class,
  		       result);
      } catch (BSFException e) {
        throw new SOAPException (Constants.FAULT_CODE_SERVER,
  			       "BSF Error: " + e.getMessage (), e);
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/SMTP2HTTPBridge.java
  
  Index: SMTP2HTTPBridge.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.server;
  
  import java.net.*;
  import java.util.*;
  
  import com.ibm.network.mail.base.*;
  import com.ibm.network.mail.smtp.event.*;
  import org.apache.soap.util.net.*;
  import org.apache.soap.util.*;
  import org.apache.soap.Constants;
  import org.apache.soap.transport.smtp.*;
  
  /**
   * This class can be used as a bridge to relay SOAP messages received via
   * email to an HTTP SOAP listener. This is basically a polling POP3 client
   * that keeps looking for new messages to work on. When it gets one,
   * it forwards it to a SOAP HTTP listener and forwards the response via
   * SMTP to the original requestor (to either the ReplyTo: or From: address).
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class SMTP2HTTPBridge implements Runnable {
    Object waitObject = new Object ();
    long pollDelayMillis;
    com.ibm.network.mail.pop3.protocol.CoreProtocolBean pop3 =
      new com.ibm.network.mail.pop3.protocol.CoreProtocolBean ();
    com.ibm.network.mail.smtp.protocol.CoreProtocolBean smtp =
      new com.ibm.network.mail.smtp.protocol.CoreProtocolBean ();
    URL httpURL;
  
    /**
     * Constructor: creates a bridge. Call run() to start polling using
     * the current thread. (If you want to use a separate thread then
     * do new Thread (new SMT2HTTPBridge (...)).start ();
     *
     * @param pollDelayMillis number of milli-seconds to sleep b'ween polls
     * @param popServer hostname of POP3 server
     * @param popLoginName login ID
     * @param password password for login
     * @param smtpServer hostname of SMTP server
     */
    public SMTP2HTTPBridge (/* POP3 params */
  			  long pollDelayMillis,
  			  String popServer, String popLoginName,
  			  String password,
  			  /* HTTP params */
  			  URL httpURL,
  			  /* SMTP params */
  			  String smtpServer) {
      /* set up the pop3 side */
      this.pollDelayMillis = pollDelayMillis;
      pop3.setPOP3ServerHost (popServer);
      pop3.setUserOptions(/* popLoginName */ popLoginName,
        /* password */ password,
        /* leaveMessagesOnServer */ false,
        /* rememberPassword */ false);
      pop3.addMessageListener (
        new com.ibm.network.mail.pop3.event.MessageListener () {
          public void messageReceived (
  	    com.ibm.network.mail.pop3.event.MessageEvent me) {
  	  receiveMessage (me.getMessage ());
  	}
        }
      );
      pop3.addStatusListener (new POP3StatusListener ());
  
      /* set up the http side */
      this.httpURL = httpURL;
  
      /* set up the smtp side */
      smtp.setSmtpServerHost (smtpServer);
      smtp.addStatusListener (new StatusListener () {
        public void operationComplete (StatusEvent e) {
  	System.err.println ("DONE: " + e.getStatusString ());
  	synchronized (waitObject) {
  	  waitObject.notify ();
  	}
        }
  
        public void processStatus (StatusEvent e) {
  	System.err.println ("Status update: " + e.getStatusString ());
        }
      });
    }
  
    /**
     * Poll for messages forever.
     */
    public void run () {
      while (true) {
        if (pop3.isReady ()) {
          System.err.println ("SMTP2HTTPBridge: Polling for messages ..");
          pop3.receiveMessage ();
        }
        try {
          Thread.sleep (pollDelayMillis);
        } catch (Exception e) {
          e.printStackTrace ();
        }
      }
    }
  
    /**
     * This is called by the POP3 message listener after receiving a 
     * message from the pop server.
     * 
     * @param msg the message that was received
     */
    void receiveMessage (MimeMessage msg) {
      /* extract the stuff from the SMTP message received */
      String subject = msg.getHeader (SMTPConstants.SMTP_HEADER_SUBJECT);
      String actionURI = msg.getHeader (Constants.HEADER_SOAP_ACTION);
      String toAddr = msg.getHeader (SMTPConstants.SMTP_HEADER_TO);
      String fromAddr = msg.getHeader (SMTPConstants.SMTP_HEADER_FROM);
      MimeBodyPart mbp = (MimeBodyPart) msg.getContent ();
      byte[] ba = (byte[]) mbp.getContent ();
  
      /* forward the content to the HTTP listener as an HTTP POST */
      Hashtable headers = new Hashtable ();
      headers.put (Constants.HEADER_SOAP_ACTION, actionURI);
      org.apache.soap.util.net.HTTPUtils$Response httpResponse = 
        HTTPUtils.post (httpURL, headers, Constants.HEADERVAL_CONTENT_TYPE,
            new String (ba));
      System.err.println ("HTTP RESPONSE IS: ");
      int contentLength = httpResponse.contentLength;
      String payload = null;
      try {
        if (contentLength == -1) { // no content length; read the stream
  	payload = IOUtils.getStringFromReader (httpResponse.content);
        } else { // read contentLength chars
  	char[] payloadChars = new char[contentLength];
  	int offset = 0;
  	while (offset < contentLength) {
  	  offset += httpResponse.content.read (payloadChars, offset,
  					       contentLength - offset);
  	}
  	payload = new String (payloadChars);
        }
      } catch (Exception e) {
        e.printStackTrace ();
      }
      System.err.println ("'" + payload + "'");
  
      /* forward the response via SMTP to the original sender */
      MimeBodyPart mbpResponse = new MimeBodyPart ();
      mbpResponse.setContent (new String (payload), httpResponse.contentType);
      mbpResponse.setEncoding (MimePart.SEVENBIT);
      mbpResponse.setDisposition (MimePart.INLINE);
  
      MimeMessage msgResponse = new MimeMessage();
      msgResponse.setContent (mbpResponse, "");
      msgResponse.addHeader (SMTPConstants.SMTP_HEADER_SUBJECT,
  			   "Re: " + subject);
      msgResponse.addHeader (Constants.HEADER_SOAP_ACTION, actionURI);
      msgResponse.addHeader (SMTPConstants.SMTP_HEADER_FROM, 
  			   SMTPUtils.getAddressFromAddressHeader (toAddr));
      String sendTo = SMTPUtils.getAddressFromAddressHeader (fromAddr);
      msgResponse.addRecipients (MimeMessage.TO, 
                                 new InternetAddress[] { 
                                   new InternetAddress (sendTo)
  			       });
      smtp.sendMessage (msgResponse);
    }
  
    public static void main (String[] args) throws Exception {
      if (args.length != 6) {
        System.err.println ("Usage: java " + SMTP2HTTPBridge.class.getName () +
  			  " polldelay \\");
        System.err.println ("\t\t pop3host pop3login pop3passwd httpurl " +
  			  "smtphostname");
        System.err.println ("  where:");
        System.err.println ("    polldelay    number of millisec to " +
  			  "sleep between polls");
        System.err.println ("    pop3host     hostname of the POP3 server");
        System.err.println ("    pop3login    login ID of POP3 account");
        System.err.println ("    pop3passwd   POP3 account password");
        System.err.println ("    routerURL    http URL of SOAP router to " +
  			  "bridge to");
        System.err.println ("    smtphostname SMTP server host name");
        System.exit (1);
      }
      SMTP2HTTPBridge sb = new SMTP2HTTPBridge (/* POP3 params */
  					      Integer.parseInt (args[0]),
  					      args[1],
  					      args[2],
  					      args[3],
  					      /* HTTP params */
  					      new URL (args[4]),
  					      /* SMTP params */
  					      args[5]);
      new Thread (sb).start ();
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/ServerConstants.java
  
  Index: ServerConstants.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.server;
  
  /**
   * Server-side <em>SOAP</em> constants.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class ServerConstants {
    // service name of the service manager
    public static final String SERVICE_MANAGER_SERVICE_NAME =
    "urn:ibm-soap-service-management-service";
  
    // HTTP status codes.
    public static final int SC_BAD_REQUEST = 400;
    public static final int SC_INTERNAL_SERVER_ERROR = 500;
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/ServiceManager.java
  
  Index: ServiceManager.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.server;
  
  import java.util.*;
  import java.io.*;
  import org.apache.soap.util.xml.QName;
  import org.apache.soap.*;
  
  /**
   * A <code>ServiceManager</code> manages services and their associated
   * <code>DeploymentDescriptors</code>.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class ServiceManager {
    Hashtable dds;
    String filename = "DeployedServices.ds";
    // service management service's deployment descriptor 
    DeploymentDescriptor smsdd;
    String[] serviceNamesCache;
  
    public ServiceManager () {
      smsdd = new DeploymentDescriptor ();
      smsdd.setID (ServerConstants.SERVICE_MANAGER_SERVICE_NAME);
      String[] svcs = new String[] { "deploy", "undeploy", "list",  "query" };
      smsdd.setMethods (svcs);
      smsdd.setScope (DeploymentDescriptor.SCOPE_APPLICATION);
      smsdd.setProviderType (DeploymentDescriptor.PROVIDER_JAVA);
      smsdd.setProviderClass ("org.apache.soap.server.ServiceManager");
      smsdd.setIsStatic (false);
  
      // set up mappings to send/recv DeploymentDescriptor and TypeMapping
      // objects
      smsdd.setMappings (new TypeMapping[] {
        new TypeMapping (Constants.NS_URI_SOAP_ENC,
  		       new QName (Constants.NS_URI_IBM_SOAP,
  				  "DeploymentDescriptor"),
  		       "org.apache.soap.server.DeploymentDescriptor",
  		       "org.apache.soap.encoding.soapenc.BeanSerializer",
  		       "org.apache.soap.encoding.soapenc.BeanSerializer"),
        new TypeMapping (Constants.NS_URI_SOAP_ENC,
  		       new QName (Constants.NS_URI_IBM_SOAP,
  				  "TypeMapping"),
  		       "org.apache.soap.server.TypeMapping",
  		       "org.apache.soap.server.TypeMappingSerializer",
  		       "org.apache.soap.server.TypeMappingSerializer")});
  
      // load in a serialized thing
      try {
        FileInputStream fis = new FileInputStream (filename);
        ObjectInputStream is = new ObjectInputStream (fis);
  
        dds = (Hashtable) is.readObject ();
        is.close ();
      } catch(Exception e) {
        dds = new Hashtable ();
        System.err.println ("SOAP Service Manager: Unable to read '" +
                            filename +  "': assuming fresh start");
      }
    }
  
    private void saveRegistry () throws SOAPException {
      serviceNamesCache = null;
      try {
        FileOutputStream fos = new FileOutputStream (filename);
        ObjectOutputStream os = new ObjectOutputStream (fos);
  
        os.writeObject (dds);
        os.close ();
      } catch (Exception e) {
        throw new SOAPException (Constants.FAULT_CODE_SERVER,
  			       "Error saving services registry: " +
  			       e.getMessage ());
      };
    }
  
    /**
     * Deploy a service: add the descriptor to the persistent record of
     * what has been deployed. 
     */
    public void deploy (DeploymentDescriptor dd) throws SOAPException {
      String id = dd.getID ();
      if (id.equals (ServerConstants.SERVICE_MANAGER_SERVICE_NAME)) {
        throw new SOAPException (Constants.FAULT_CODE_SERVER,
  			       "service management service '" +
  			       ServerConstants.SERVICE_MANAGER_SERVICE_NAME +
  			       "' cannot be user deployed");
      }
      dds.put (id, dd);
      saveRegistry ();
    }
  
    /**
     * Undeploy a service: remove the descriptor from the persistent record
     * of what has been deployed.
     *
     * @id the id of the service I'm undeploying
     * @exception SOAPException if service is not found
     */
    public DeploymentDescriptor undeploy (String id) 
         throws SOAPException {
      DeploymentDescriptor dd = (DeploymentDescriptor) dds.remove (id);
      if (dd != null) {
        saveRegistry ();
      } else {
        throw new SOAPException (Constants.FAULT_CODE_SERVER,
  			       "service '" + id + "' unknown");
      }
      return dd;
    }
  
    /**
     * Return the deployment descriptor for a service. If the id identifies
     * the service management service, then the deployment descriptor of
     * the service management service is returned.
     *
     * @param id the id of the service I'm looking for
     * @exception SOAPException if service is not found
     */
    public DeploymentDescriptor query (String id) throws SOAPException {
      if (id == null) {
        return null;
      } else if (id.equals (ServerConstants.SERVICE_MANAGER_SERVICE_NAME)) {
        return smsdd;
      } else {
        DeploymentDescriptor dd = (DeploymentDescriptor) dds.get (id);
        if (dd != null) {
  	return dd;
        } else {
  	throw new SOAPException (Constants.FAULT_CODE_SERVER,
  				 "service '" + id + "' unknown");
        }
      }
    }
  
    /**
     * Return an array of all the deployed service names. Returns an array
     * of length zero if there are no deployed services.
     *
     * @return array of all service names
     */
    public String[] list () {
      if (serviceNamesCache != null) {
        return serviceNamesCache;
      }
      Enumeration e = dds.keys ();
      int count = dds.size ();
      serviceNamesCache = new String[count];
      for (int i = 0; i < count; i++) {
        serviceNamesCache[i] = (String) e.nextElement ();
      }
      return serviceNamesCache;
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/ServiceManagerClient.java
  
  Index: ServiceManagerClient.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.server;
  
  import java.net.URL;
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.SOAPMappingRegistry;
  import org.apache.soap.rpc.*;
  
  /**
   * This is a client to talk to a IBM-SOAP ServiceManager to manage services
   * deployed on the server.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class ServiceManagerClient {
    URL routerURL;
    Vector params = new Vector ();
    Call call = new Call ();
  
    public ServiceManagerClient (URL routerURL) {
      Serializer bs = new org.apache.soap.encoding.soapenc.BeanSerializer ();
  
      this.routerURL = routerURL;
      SOAPMappingRegistry smr = call.getSOAPMappingRegistry ();
  
      // register serializer/deserializer for DeploymentDescriptor.class
      // and TypeMapping.class
      smr.mapTypes (Constants.NS_URI_SOAP_ENC,
  		  new QName (Constants.NS_URI_IBM_SOAP,
  			     "DeploymentDescriptor"),
  		  DeploymentDescriptor.class, bs, (Deserializer) bs);
      bs = new TypeMappingSerializer ();
      smr.mapTypes (Constants.NS_URI_SOAP_ENC,
  		  new QName (Constants.NS_URI_IBM_SOAP, "TypeMapping"),
  		  TypeMapping.class, bs, (Deserializer) bs);
    }
  
    private Response invokeMethod (String methodName, Parameter param) 
         throws SOAPException {
      call.setTargetObjectURI (ServerConstants.SERVICE_MANAGER_SERVICE_NAME);
      call.setMethodName (methodName);
      call.setEncodingStyleURI (Constants.NS_URI_SOAP_ENC);
      if (param != null) {
        params.removeAllElements ();
        params.addElement (param);
        call.setParams (params);
      }
      Response resp = call.invoke (routerURL, "");
      if (resp.generatedFault ()) {
        Fault fault = resp.getFault ();
        System.out.println ("Ouch, the call failed: ");
        System.out.println ("  Fault Code   = " + fault.getFaultCode ());  
        System.out.println ("  Fault String = " + fault.getFaultString ());
      }  
      return resp;
    }
  
    public void deploy (DeploymentDescriptor dd) throws SOAPException {
      Parameter p1 = new Parameter ("descriptor", DeploymentDescriptor.class,
  				  dd, null);
      invokeMethod ("deploy", p1);
    }
  
    public void undeploy (String serviceName) throws SOAPException {
      Parameter p1 = new Parameter ("name", String.class, serviceName, null);
      invokeMethod ("undeploy", p1);
    }
    
    public String[] list () throws SOAPException {
      Response resp = invokeMethod ("list", null);
      if (!resp.generatedFault ()) {
        Parameter result = resp.getReturnValue ();
        return (String[]) result.getValue ();
      } else {
        return null;
      }
    }
  
    public DeploymentDescriptor query (String serviceName) throws SOAPException {
      Parameter p1 = new Parameter ("name", String.class, serviceName, null);
      Response resp = invokeMethod ("query", p1);
      if (!resp.generatedFault ()) {
        Parameter result = resp.getReturnValue ();
        return (DeploymentDescriptor) result.getValue ();
      } else {
        return null;
      }
    }
  
    private static void badUsage () {
      System.err.println ("Usage: java " +
  			ServiceManagerClient.class.getName () +
  			" url operation arguments");
      System.err.println ("where");
      System.err.println ("\turl is the IBM-SOAP router's URL whose services" +
  			" are managed");
      System.err.println ("\toperation and arguments are:");
      System.err.println ("\t\tdeploy deployment-descriptor-file.xml");
      System.err.println ("\t\tlist");
      System.err.println ("\t\tquery service-name");
      System.err.println ("\t\tundeploy service-name");
      System.exit (1);
    }
  
    /**
     * Command-line app for managing services on a SOAP4J server.
     */
    public static void main (String[] args) throws Exception {
      URL routerURL;
      String op;
  
      if (args.length < 2) {
        badUsage ();
      }
      
      ServiceManagerClient smc = new ServiceManagerClient (new URL (args[0]));
  
      op = args[1];
      if (op.equals ("deploy")) {
        if (args.length != 3) {
  	badUsage ();
        }
        FileReader fr = new FileReader (args[2]);
        XMLParserLiaison xpl = new XercesParserLiaison ();
        Document doc = xpl.read (args[2], fr);
        smc.deploy (DeploymentDescriptor.fromXML (doc.getDocumentElement ()));
      } else if (op.equals ("undeploy")) {
        if (args.length != 3) {
  	badUsage ();
        }
        smc.undeploy (args[2]);
      } else if (op.equals ("list")) {
        String[] sms = smc.list ();
        if (sms != null) {
  	System.out.println ("Deployed Services:");
  	for (int i = 0; i < sms.length; i++) {
  	  System.out.println ("\t" + sms[i]);
  	}
        }
      } else if (op.equals ("query")) {
        if (args.length != 3) {
  	badUsage ();
        }
        DeploymentDescriptor dd = smc.query (args[2]);
        if (dd != null) {
  	dd.toXML (new OutputStreamWriter (System.out));
        }
      } else {
        badUsage ();
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/TypeMapping.java
  
  Index: TypeMapping.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.server;
  
  import java.io.Serializable;
  import org.apache.soap.util.xml.QName;
  
  /**
   * This class keeps all the info about a type mapping: the encoding style,
   * the XML element type, the Java type that's spsed to map to and the names
   * of the Java classes that implement the mapping between XML and Java.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class TypeMapping implements Serializable {
    public String encodingStyle;
    public QName elementType;
    public String javaType;
    public String java2XMLClassName;
    public String xml2JavaClassName;
  
    public TypeMapping (String encodingStyle, QName elementType, String javaType,
            String java2XMLClassName, String xml2JavaClassName) {
      this.encodingStyle = encodingStyle;
      this.elementType = elementType;
      this.javaType = javaType;
      this.java2XMLClassName = java2XMLClassName;
      this.xml2JavaClassName = xml2JavaClassName;
    }
  
    public String toString () {
      return "[TypeMapping encodingStyle=" + encodingStyle + "," +
        "elementType=" + elementType + "," +
        "javaType=" + javaType + "," +
        "java2XMLClassName=" + java2XMLClassName + "," +
        "xml2JavaClassName=" + xml2JavaClassName + "]";
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/TypeMappingSerializer.java
  
  Index: TypeMappingSerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.server;
  
  import java.util.*;
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.Bean;
  import org.apache.soap.util.StringUtils;
  import org.apache.soap.util.DOMUtils;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.Constants;
  import org.apache.soap.encoding.*;
  import org.apache.soap.encoding.soapenc.SoapEncUtils;
  
  import java.io.*;
  
  /**
   * Serialize and deserialize type mappings according to SOAP-Enc.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class TypeMappingSerializer implements Serializer, Deserializer {
    /**
     * This is the Serializer interface .. called to serialize an instance
     * of a TypeMapping (the src arg)
     * @param inScopeEncStyle the encoding style currently in scope
     * @param javaType should be org.apache.soap.server.TypeMapping.class
     * @param src instance to serialize as XML
     * @param context accessor name
     * @param sink the writer to write XML into
     * @param nsStack namespace stack
     * @param xjmr unused
     */
    public void marshall (String inScopeEncStyle, Class javaType, Object src,
  			Object context, Writer sink, NSStack nsStack,
  			XMLJavaMappingRegistry xjmr)
         throws IllegalArgumentException, IOException {
      TypeMapping tm = (TypeMapping) src;
  
      nsStack.pushScope ();
      SoapEncUtils.generateStructureHeader (inScopeEncStyle, javaType, context, 
  					  sink, nsStack, xjmr);
      sink.write (StringUtils.lineSeparator);
  
      // these namespaces being defined by the envelope stuff
      String xsiPrefix = nsStack.getPrefixFromURI (Constants.NS_URI_SCHEMA_XSI);
      String xsdPrefix = nsStack.getPrefixFromURI (Constants.NS_URI_SCHEMA_XSD);
      if ((xsiPrefix == null) || (xsdPrefix == null)) {
        throw new IllegalArgumentException ("required namespace names '" +
  					  Constants.NS_URI_SCHEMA_XSI + 
  					  "' and/or '" +
  					  Constants.NS_URI_SCHEMA_XSD + 
  					  "' is not defined.");
      }
  
      sink.write ("<encodingStyle " + xsiPrefix + ":type=\"" + xsdPrefix + 
  		":string\">" + tm.encodingStyle + "</encodingStyle>");
      sink.write (StringUtils.lineSeparator);
  
      sink.write ("<elementType-ns " + xsiPrefix + ":type=\"" + xsdPrefix + 
  		":string\">" + tm.elementType.getNamespaceURI () +
  		"</elementType-ns>");
      sink.write (StringUtils.lineSeparator);
  
      sink.write ("<elementType-lp " + xsiPrefix + ":type=\"" + xsdPrefix + 
  		":string\">" + tm.elementType.getLocalPart () +
  		"</elementType-lp>");
      sink.write (StringUtils.lineSeparator);
  
      sink.write ("<javaType " + xsiPrefix + ":type=\"" + xsdPrefix + 
  		":string\">" + tm.javaType + "</javaType>");
      sink.write (StringUtils.lineSeparator);
  
      sink.write ("<xml2JavaClassName " + xsiPrefix + ":type=\"" + xsdPrefix + 
  		":string\">" + tm.xml2JavaClassName + "</xml2JavaClassName>");
      sink.write (StringUtils.lineSeparator);
  
      sink.write ("<java2XMLClassName " + xsiPrefix + ":type=\"" + xsdPrefix + 
  		":string\">" + tm.java2XMLClassName + "</java2XMLClassName>");
      sink.write (StringUtils.lineSeparator);
  
      sink.write ("</" + context + '>');
      nsStack.popScope ();
    }
  
  
    /**
     * The deserializer interface.
     */
    public Bean unmarshall (String inScopeEncStyle, QName elementType, Node src,
  			  XMLJavaMappingRegistry xjmr)
         throws IllegalArgumentException {
      NodeList nl = src.getChildNodes ();
      int nKids = nl.getLength ();
  
      // info for the type mapping object
      String encodingStyle = null;
      String elTypeNS = null;
      String elTypeLP = null;
      String javaType = null;
      String java2XMLClassName = null;
      String xml2JavaClassName = null;
  
      for (int i = 0; i < nKids; i++) {
        Node n = nl.item (i);
        if (n.getNodeType () != Node.ELEMENT_NODE) {
  	continue;
        }
        Element e = (Element) n;
        String tagName = e.getTagName ();
        String elData = DOMUtils.getChildCharacterData (e);
        if (tagName.equals ("encodingStyle")) {
  	encodingStyle = elData;
        } else if (tagName.equals ("elementType-ns")) {
  	elTypeNS = elData;
        } else if (tagName.equals ("elementType-lp")) {
  	elTypeLP = elData;
        } else if (tagName.equals ("javaType")) {
  	javaType = elData;
        } else if (tagName.equals ("java2XMLClassName")) {
  	java2XMLClassName = elData;
        } else if (tagName.equals ("xml2JavaClassName")) {
  	xml2JavaClassName = elData;
        } else {
  	throw new IllegalArgumentException ("unknown element '" +
  					    tagName + "' while " + 
  					    "unmarshalling a TypeMapping");
        }
      }
      return new Bean (TypeMapping.class,
  		     new TypeMapping (encodingStyle, 
  				      new QName (elTypeNS, elTypeLP),
  				      javaType,
  				      java2XMLClassName, xml2JavaClassName));
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/blankpage.html
  
  Index: blankpage.html
  ===================================================================
  <b>What do you want to do today?</b>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/deploy.gif
  
  	<<Binary file>>
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/deploy.jsp
  
  Index: deploy.jsp
  ===================================================================
  <%@ page import="java.io.*, java.util.*, org.w3c.dom.*" %>
  <%@ page import="org.apache.soap.util.*, org.apache.soap.util.xml.*, org.apache.soap.server.*" %>
  
  <!-- get the serviceManager object -->
  <jsp:useBean id="serviceManager" 
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <h1>Deploy a Service</h1>
  
  <% 
  if (!request.getMethod().equals ("POST")) { 
  %>
  
  <form action="deploy.jsp" method="POST">
      <table border="1" width="100%">
          <tr>
              <th colspan="2"><h2>Service Deployment Descriptor
              Template</h2>
              </th>
          </tr>
          <tr>
              <th>Property</th>
              <th>Details</th>
          </tr>
          <tr>
              <td>ID</td>
              <td><input type="text" size="60" name="id"></td>
          </tr>
          <tr>
              <td>Scope</td>
              <td><select name="scope" size="1">
                  <option selected value="0">Page</option>
                  <option value="1">Request</option>
                  <option value="2">Session</option>
                  <option value="3">Application</option>
              </select></td>
          </tr>
          <tr>
              <td>Methods</td>
              <td><input type="text" size="60" name="methods"><br>
              (Whitespace separated list of method names) </td>
          </tr>
          <tr>
              <td>Provider Type</td>
              <td><select name="providerType" size="1">
                  <option selected value="0">Java</option>
                  <option value="1">Script</option>
              </select></td>
          </tr>
          <tr>
              <td>Java Provider</td>
              <td><div align="left"><table border="0">
                  <tr>
                      <td>Provider Class</td>
                      <td><input type="text" size="40"
                      name="providerClass"></td>
                  </tr>
                  <tr>
                      <td width="150">Static?</td>
                      <td><select name="isStatic" size="1">
                          <option value="true">Yes</option>
                          <option selected value="no">No</option>
                      </select></td>
                  </tr>
              </table>
              </div></td>
          </tr>
          <tr>
              <td>Script Provider</td>
              <td><div align="left"><table border="0">
                  <tr>
                      <td>Script Language</td>
                      <td><select name="scriptLanguage" size="1">
                          <option value="bml">BML</option>
                          <option value="jacl">Jacl</option>
                          <option value="javascript">JavaScript (Rhino)</option>
                          <option value="jpython">JPython</option>
                          <option value="jscript">JScript</option>
                          <option value="perlscript">PerlScript</option>
                          <option value="vbscript">VBScript</option>
                          <option value="other">Other .. (type in)</option>
                      </select><input type="text" size="20"
                      name="scriptLanguageTypein"></td>
                  </tr>
                  <tr>
                      <td width="150">Script Filename, or</td>
                      <td><input type="text" size="40"
                      name="scriptFilename"></td>
                  </tr>
                  <tr>
                      <td>Script</td>
                      <td><textarea name="script" rows="10"
                      cols="40"></textarea></td>
                  </tr>
              </table>
              </div></td>
          </tr>
          <tr>
              <td>Type Mappings</td>
              <td>Number of mappings: <input type="text" size="10"
              name="nmaps" /><br>
              <div align="center"><center><table border="0">
                  <tr>
                      <td align="center" rowspan="2">Encoding Style</td>
                      <td align="center" colspan="2">Element Type </td>
                      <td align="center" rowspan="2">Java Type</td>
                      <td align="center" rowspan="2">Java to XML
                      Serializer </td>
                      <td align="center" rowspan="2">XML to Java
                      Deserializer </td>
                  </tr>
                  <tr>
                      <td align="center">Namespace URI</td>
                      <td align="center">Local Part</td>
                  </tr>
                  <tr>
                      <td><select name="encstyle1" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri1"></td>
                      <td><input type="text" size="10"
                      name="localpart1"></td>
                      <td><input type="text" size="15"
                      name="classname1"></td>
                      <td><input type="text" size="15"
                      name="java2xml1"></td>
                      <td><input type="text" size="15"
                      name="xml2java1"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle2" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri2"></td>
                      <td><input type="text" size="10"
                      name="localpart2"></td>
                      <td><input type="text" size="15"
                      name="classname2"></td>
                      <td><input type="text" size="15"
                      name="java2xml2"></td>
                      <td><input type="text" size="15"
                      name="xml2java2"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle3" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri3"></td>
                      <td><input type="text" size="10"
                      name="localpart3"></td>
                      <td><input type="text" size="15"
                      name="classname3"></td>
                      <td><input type="text" size="15"
                      name="java2xml3"></td>
                      <td><input type="text" size="15"
                      name="xml2java3"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle4" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri4"></td>
                      <td><input type="text" size="10"
                      name="localpart4"></td>
                      <td><input type="text" size="15"
                      name="classname4"></td>
                      <td><input type="text" size="15"
                      name="java2xml4"></td>
                      <td><input type="text" size="15"
                      name="xml2java4"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle5" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri5"></td>
                      <td><input type="text" size="10"
                      name="localpart5"></td>
                      <td><input type="text" size="15"
                      name="classname5"></td>
                      <td><input type="text" size="15"
                      name="java2xml5"></td>
                      <td><input type="text" size="15"
                      name="xml2java5"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle6" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri6"></td>
                      <td><input type="text" size="10"
                      name="localpart6"></td>
                      <td><input type="text" size="15"
                      name="classname6"></td>
                      <td><input type="text" size="15"
                      name="java2xml6"></td>
                      <td><input type="text" size="15"
                      name="xml2java6"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle7" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri7"></td>
                      <td><input type="text" size="10"
                      name="localpart7"></td>
                      <td><input type="text" size="15"
                      name="classname7"></td>
                      <td><input type="text" size="15"
                      name="java2xml7"></td>
                      <td><input type="text" size="15"
                      name="xml2java7"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle8" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri8"></td>
                      <td><input type="text" size="10"
                      name="localpart8"></td>
                      <td><input type="text" size="15"
                      name="classname8"></td>
                      <td><input type="text" size="15"
                      name="java2xml8"></td>
                      <td><input type="text" size="15"
                      name="xml2java8"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle9" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri9"></td>
                      <td><input type="text" size="10"
                      name="localpart9"></td>
                      <td><input type="text" size="15"
                      name="classname9"></td>
                      <td><input type="text" size="15"
                      name="java2xml9"></td>
                      <td><input type="text" size="15"
                      name="xml2java9"></td>
                  </tr>
                  <tr>
                      <td><select name="encstyle10" size="1">
                          <option selected value="0">SOAP</option>
                          <option value="1">XMI</option>
                          <option value="2">BML</option>
                      </select></td>
                      <td><input type="text" size="15"
                      name="nsuri10"></td>
                      <td><input type="text" size="10"
                      name="localpart10"></td>
                      <td><input type="text" size="15"
                      name="classname10"></td>
                      <td><input type="text" size="15"
                      name="java2xml10"></td>
                      <td><input type="text" size="15"
                      name="xml2java10"></td>
                  </tr>
              </table>
              </center></div></td>
          </tr>
      </table>
      <p><input type="submit" value="Deploy" /></p>
  </form>
  
  <%
  } else {
    String id = request.getParameter ("id");
    DeploymentDescriptor dd = new DeploymentDescriptor ();
    dd.setID (id);
  
    // get the provider info
    int scope = Integer.parseInt (request.getParameter ("scope"));
    String providerTypeStr = request.getParameter ("providerType");
    String className = request.getParameter ("providerClass");
    boolean isStatic = request.getParameter ("isStatic").equals ("true");
    String scriptLang = request.getParameter ("scriptLanguage");
    if (scriptLang.equals ("other")) {
      scriptLang = request.getParameter ("scriptLanguageTypeIn");
    }
    String scriptFilename = request.getParameter ("scriptFilename");
    String script = request.getParameter ("script");
    String methodsStr = request.getParameter ("methods");
    StringTokenizer st = new StringTokenizer (methodsStr);
    int nTokens = st.countTokens ();
    String[] methods = new String[nTokens];
    for (int i = 0; i < nTokens; i++) {
      methods[i] = st.nextToken ();
    }
  
    dd.setScope (scope);
    dd.setMethods (methods);
  
    if (providerTypeStr.equals ("0")) {
      dd.setProviderType (DeploymentDescriptor.PROVIDER_JAVA);
      dd.setProviderClass (className);
      dd.setIsStatic (isStatic);
    } else {
      if (!scriptFilename.equals ("")) { // filename specified
        dd.setProviderType (DeploymentDescriptor.PROVIDER_SCRIPT_FILE);
      } else { // there better be a script to run
        dd.setProviderType (DeploymentDescriptor.PROVIDER_SCRIPT_STRING);
      }
      dd.setScriptLanguage (scriptLang);
      dd.setScriptFilenameOrString (scriptFilename);
    }
  
    String[] encs = {org.apache.soap.Constants.NS_URI_SOAP_ENC,
         org.apache.soap.Constants.NS_URI_XMI_ENC,
         org.apache.soap.Constants.NS_URI_BML_ENC};
  
    // set up any type mappings
    int nmaps = 0;
  
    try {
      nmaps = Integer.parseInt (request.getParameter ("nmaps"));
    } catch (NumberFormatException e) {
    }
  
    if (nmaps != 0) {
      TypeMapping[] mappings = new TypeMapping[nmaps];
      for (int i = 1; i <= nmaps; i++) { // the form is hard-coded to a max of 10
        int encStyle = Integer.parseInt (request.getParameter ("encstyle" + i));
        String nsuri = request.getParameter ("nsuri" + i);
        String localPart = request.getParameter ("localpart" + i);
        String classNameStr = request.getParameter ("classname" + i);
        String java2XMLClass = request.getParameter ("java2xml" + i);
        String xml2JavaClass = request.getParameter ("xml2java" + i);
        QName elementType = (nsuri.equals ("") || localPart.equals ("")) 
                            ? null : new QName (nsuri, localPart);
        // map "" to null (the unfilled params come as empty strings because
        // they are infact actual parameters)
        classNameStr = classNameStr.equals ("") ? null : classNameStr;
        java2XMLClass = java2XMLClass.equals ("") ? null : java2XMLClass;
        xml2JavaClass = xml2JavaClass.equals ("") ? null : xml2JavaClass;
        mappings[i-1] = new TypeMapping (encs[encStyle], elementType,
  				       classNameStr, java2XMLClass,
  				       xml2JavaClass);
      }
      dd.setMappings (mappings);
    }
  
    // ok now deploy it
    serviceManager.deploy (dd);
  
    // show what was deployed
    out.println ("<p>Service <b>" + dd.getID () + "</b> deployed.</p>");
  }
  %>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/header.html
  
  Index: header.html
  ===================================================================
  <center>
  <img src="soapadmin.gif"/>
  </center>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/index.html
  
  Index: index.html
  ===================================================================
  <html>
    <head>
      <title>IBM-SOAP Admin Tool</title>
  
      <script language="JavaScript" type="text/javascript">
        <!-- Hide from non-scripting browsers
        function refresh()
        {
          toc.location.reload();
          data.location.href='blankpage.html';
        }
        // -->
      </script>
    </head>
  
    <frameset rows="90,*" border="0">
      <frame name="image" src="header.html">
      <frameset cols="150,*" border="0">
        <frame name="toc" src="toc.html">
        <frame name="data" src="blankpage.html">
      </frameset>
    </frameset>
  </html>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/list.gif
  
  	<<Binary file>>
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/list.jsp
  
  Index: list.jsp
  ===================================================================
  <%@ page import="java.util.*, org.apache.soap.server.*" %>
  
  <!-- get the serviceManager object -->
  <jsp:useBean id="serviceManager" 
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <h1>Service Listing</h1>
  
  <% 
    String[] serviceNames = serviceManager.list ();
    if (serviceNames.length == 0) {
      out.println ("<p>Sorry, there are no services currently deployed.</p>");
    } else {
      out.println ("<p>Here are the deployed services (select one to see");
      out.println ("details)</p>");
      %>
      <ul>
      <%
      for (int i = 0; i < serviceNames.length; i++) {
        String id = serviceNames[i];
      %>
        <li><a href="showdetails.jsp?id=<%=id%>"><%= id%></li>
      <%
      }
      %>
      </ul>
      <%
    }
  %>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/rpcrouter.jsp
  
  Index: rpcrouter.jsp
  ===================================================================
  <%@ page language="java" %>
  
  <%@ page import="java.io.*" %>
  <%@ page import="java.util.*" %>
  <%@ page import="java.lang.reflect.*" %>
  <%@ page import="org.w3c.dom.*" %>
  <%@ page import="org.apache.soap.util.Bean" %>
  <%@ page import="org.apache.soap.util.ReflectionUtils" %>
  <%@ page import="org.apache.soap.util.IOUtils" %>
  <%@ page import="org.apache.soap.util.StringUtils" %>
  <%@ page import="org.apache.soap.util.xml.XMLParserLiaison" %>
  <%@ page import="org.apache.soap.util.xml.XercesParserLiaison" %>
  <%@ page import="org.apache.soap.*" %>
  <%@ page import="org.apache.soap.encoding.*" %>
  <%@ page import="org.apache.soap.rpc.*" %>
  <%@ page import="org.apache.soap.server.*" %>
  
  <jsp:useBean id="serviceManager"
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <%
  Response resp = null;
  String targetID = null;
  
  // Query the relevant header fields.
  String requestMethod = request.getMethod ();
  String contentType = request.getContentType ();
  int contentLength = request.getContentLength ();
  
  Call call = null;
  
  try
  {
    if (requestMethod == null ||
        !requestMethod.equals (Constants.HEADER_POST))
    {
      throw new SOAPException (Constants.FAULT_CODE_PROTOCOL,
                               "Can only respond to '" +
                               Constants.HEADER_POST + "' requests.");
    }
    else if (contentType == null
             || !contentType.equals (Constants.HEADERVAL_CONTENT_TYPE))
    {
      throw new SOAPException (Constants.FAULT_CODE_PROTOCOL,
                               "Content type must be: '" +
                               Constants.HEADERVAL_CONTENT_TYPE + "'.");
    }
    else if (contentLength < 0)
    {
      throw new SOAPException (Constants.FAULT_CODE_PROTOCOL,
                               "Content length must be specified.");
    }
    else
    {
      System.err.println (">>(" + new Date() +
                          ") Processing SOAP request...");
  
      response.setContentType (Constants.HEADERVAL_CONTENT_TYPE);
  
      Reader requestReader = request.getReader ();
      char[] payload       = new char[contentLength];
      int    offset        = 0;
  
      while (offset < contentLength) {
        offset += requestReader.read (payload, offset, contentLength - offset);
      }
  
      // Parse the incoming request stream.
      org.apache.soap.util.xml.XMLParserLiaison xpl = new XercesParserLiaison ();
      Document callDoc = xpl.read("- SOAP HTTP RPC Call Envelope -",
                                  new CharArrayReader (payload));
      Element payloadEl = null;
  
      if (callDoc == null) {
        throw new SOAPException(Constants.FAULT_CODE_PROTOCOL,
                                "DOM parsing error: " + payload);
      }
  
      payloadEl = callDoc.getDocumentElement ();
  
      try {
        // Unmarshall the call envelope.
        Envelope callEnv = Envelope.unmarshall (payloadEl);
  
        // Extract the call from the call envelope.
        call = Call.extractFromEnvelope (callEnv, serviceManager);
      } catch (IllegalArgumentException e) {
        String msg = e.getMessage ();
        String faultCode = (msg != null
                            && msg.equals(Constants.ERR_MSG_VERSION_MISMATCH))
                           ? Constants.FAULT_CODE_VERSION_MISMATCH
                           : Constants.FAULT_CODE_CLIENT;
  
        throw new SOAPException (faultCode, msg, e);
      }
  
      // good call?
      targetID = call.getTargetObjectURI ();
      if (targetID == null) {
        throw new SOAPException (
          RPCConstants.FAULT_CODE_SERVER_BAD_TARGET_OBJECT_URI,
          "Unable to determine object id from call: is the method element " +
  	"namespaced?");
      }
  
      DeploymentDescriptor dd = serviceManager.query (targetID);
      int scope = dd.getScope ();
      byte providerType = dd.getProviderType ();
      String className;
      Object targetObject = null;
      if (providerType == DeploymentDescriptor.PROVIDER_JAVA) {
        className = dd.getProviderClass ();
      } else {
        // for scripts, we need a new BSF manager basically
        className = "com.ibm.bsf.BSFManager";
      }
  
      // make sure the method that's being called is published ..
      boolean ok = false;
      String callMethodName = call.getMethodName ();
      String[] pubMethods = dd.getMethods ();
      for (int i = 0; i < pubMethods.length; i++) {
        if (callMethodName.equals (pubMethods[i])) {
          ok = true;
          break;
        }
      }
      if (!ok) {
        throw new SOAPException (Constants.FAULT_CODE_SERVER,
                                 "Method '" + callMethodName + "' is not " +
                                 "supported.");
      }
  
      // determine the scope and lock object to use to manage the lifecycle
      // of the service providing object
      int[] iScopes = {PageContext.PAGE_SCOPE, PageContext.REQUEST_SCOPE,
  			    PageContext.SESSION_SCOPE,
  			    PageContext.APPLICATION_SCOPE};
      int iScope = iScopes[scope];
      Object[] scopeLocks = {pageContext, request, session, application};
      Object scopeLock = scopeLocks[scope];
  
      boolean freshObject = false;
  
      // find the target object on which the requested method should
      // be invoked
      if (targetID.equals (ServerConstants.SERVICE_MANAGER_SERVICE_NAME)) {
        targetObject = serviceManager;
      } else {
        // locate (or create) the target object and invoke the method
        synchronized (scopeLock) {
          targetObject = pageContext.getAttribute (targetID, iScope);
          if (targetObject == null) {
            try {
              Class c = Class.forName (className);
              if (dd.getIsStatic ()) {
                targetObject = c;
              } else {
                targetObject = c.newInstance ();
              }
              freshObject = true;
            } catch (Exception e) {
  	    String msg;
  	    if (providerType == DeploymentDescriptor.PROVIDER_JAVA) {
  	      msg = "Unable to resolve target object: " + e.getMessage ();
  	    } else {
  	      msg = "Unable to load BSF: script services not available " +
  		"without BSF: " + e.getMessage ();
  	    }
              throw new SOAPException (
                RPCConstants.FAULT_CODE_SERVER_BAD_TARGET_OBJECT_URI,
                msg, e);
            }
          }
          pageContext.setAttribute (targetID, targetObject, iScope);
        }
      }
        
      // build the args and determine response encoding style
      Vector params = call.getParams ();
      String respEncStyle = call.getEncodingStyleURI ();
      Object[] args = null;
      Class[] argTypes = null;
      if (params != null) {
        int paramsCount = params.size ();
        args = new Object[paramsCount];
        argTypes = new Class[paramsCount];
        for (int i = 0; i < paramsCount; i++) {
          Parameter param = (Parameter) params.elementAt (i);
          args[i] = param.getValue ();
          argTypes[i] = param.getType ();
          if (respEncStyle == null) {
            respEncStyle = param.getEncodingStyleURI ();
          }
        }
      }
      if (respEncStyle == null) {
        // need to set a default encoding to be used for the response
        respEncStyle = Constants.NS_URI_SOAP_ENC;
      }
      
      // invoke the method (directly for Java and via InvokeBSF for script
      // methods)
      Bean result = null;
      try {
        if (providerType == DeploymentDescriptor.PROVIDER_JAVA) {
  	Method m = ReflectionUtils.getMethod (targetObject, callMethodName,
  					      argTypes);
  	result = new Bean (m.getReturnType (), m.invoke (targetObject, args));
        } else {
  	// find the class that provides the BSF services (done
  	// this way via reflection to avoid a static dependency on BSF)
  	Class bc = Class.forName ("org.apache.soap.server.InvokeBSF");
  
          if (freshObject) {
            // get the script string to exec
            String script = dd.getScriptFilenameOrString ();
            if (providerType == DeploymentDescriptor.PROVIDER_SCRIPT_FILE) {
              String fileName = getServletContext().getRealPath (script);
              script = IOUtils.getStringFromReader (new FileReader (fileName));
            }
            
  	  // exec it
            Class[] sig = {DeploymentDescriptor.class,
                           Object.class,
                           String.class};
            Method m = ReflectionUtils.getMethod (bc, "init", sig, true);
            m.invoke (null, new Object[] {dd, targetObject, script});
          }
  
          // now invoke the service
          Class[] sig = {DeploymentDescriptor.class,
                         Object.class,
                         String.class,
                         Object[].class};
          Method m = ReflectionUtils.getMethod (bc, "service", sig, true);
          result = (Bean) m.invoke (null, new Object[] {dd, targetObject, 
                                                        callMethodName, args});
        }
      } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException ();
        throw new SOAPException (Constants.FAULT_CODE_SERVER, t.getMessage(), t);
      } catch (ClassNotFoundException e) {
        throw new SOAPException (Constants.FAULT_CODE_SERVER,
  			       "Unable to load BSF: script services " +
  			       "unsupported with BSF", e);
      } catch (Throwable t) {
        throw new SOAPException (Constants.FAULT_CODE_SERVER, t.getMessage(), t);
      }
     
      // build the response object
      Parameter ret = null;
      if (result.type != void.class) {
        ret = new Parameter (RPCConstants.ELEM_RETURN, result.type, 
  			   result.value, null);
      }
      resp = new Response (targetID, callMethodName, ret, null, null,
  			 respEncStyle);
    }
  }
  catch (SOAPException e)
  {
    Fault fault = new Fault ();
    String faultCode = e.getFaultCode ();
    String faultString = e.getMessage ();
    boolean returnSOAPResponse = true;
  
    if (faultCode == null || faultCode.startsWith (Constants.FAULT_CODE_SERVER))
    {
      response.setStatus (ServerConstants.SC_INTERNAL_SERVER_ERROR);
    }
    else if (faultCode.startsWith (Constants.FAULT_CODE_CLIENT))
    {
      response.setStatus (ServerConstants.SC_BAD_REQUEST);
    }
    else if (faultCode.startsWith (Constants.FAULT_CODE_PROTOCOL))
    {
      response.setStatus (ServerConstants.SC_BAD_REQUEST);
      returnSOAPResponse = false;
    }
  
    if (returnSOAPResponse)
    {
      fault.setFaultCode (faultCode);
      fault.setFaultString (faultString);
      fault.setFaultActorURI (request.getRequestURI ());
  
      resp = new Response (null,
                           null,
                           fault,
                           null,
                           null,
                           null);
    }
    else
    {
      out.println (faultString);
    }
  }
  catch (Throwable t)
  {
    t.printStackTrace ();
    t.printStackTrace (new PrintWriter (out));
  }
  
  // Send it out.
  if (resp != null)
  {
    try
    {
      // Build an envelope containing the response.
      Envelope respEnvelope = resp.buildEnvelope ();
      SOAPMappingRegistry smr = (call != null
                                 ? call.getSOAPMappingRegistry ()
                                 : new SOAPMappingRegistry());
  
      respEnvelope.marshall (out, smr);
  
      out.println (StringUtils.lineSeparator);
    }
    catch (IllegalArgumentException e)
    {
      throw new SOAPException (Constants.FAULT_CODE_SERVER, e.getMessage(), e);
    }
    catch (IOException e)
    {
      throw new SOAPException (Constants.FAULT_CODE_SERVER, e.getMessage(), e);
    }
  }
  %>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/showdetails.jsp
  
  Index: showdetails.jsp
  ===================================================================
  <%@ page import="java.util.*, org.apache.soap.server.*, org.apache.soap.util.xml.*" %>
  
  <!-- get the serviceManager object -->
  <jsp:useBean id="serviceManager" 
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <h1>Deployed Service Information</h1>
  
  <% 
    String id = request.getParameter ("id");
    DeploymentDescriptor dd = (id != null) 
                              ? serviceManager.query (id) 
  			    : null;
    String[] scopes = {"Page", "Request", "Session", "Application"}; 
  
    if (id == null) {
      out.println ("<p>Huh? You hafta select a service to display ..</p>");
    } else if (dd == null) {
      out.println ("<p>Service '" + id + "' is not known.</p>");
    } else {
      out.println ("<table border='1' width='100%'>");
      out.println ("<tr>");
      out.println ("<th colspan='2'><h2>'" + id + 
  		 "' Service Deployment Descriptor</h2></th>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<th>Property</th>");
      out.println ("<th>Details</th>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>ID</td>");
      out.println ("<td>" + dd.getID()+ "</td>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>Scope</td>");
      out.println ("<td>" + scopes[dd.getScope()]+ "</td>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>Provider Type</td>");
      byte ptb = dd.getProviderType ();
      String pt = (ptb==DeploymentDescriptor.PROVIDER_JAVA) ? "java" : "script";
      out.println ("<td>" + pt + "</td>");
      out.println ("</tr>");
      out.println ("<tr>");
      if (ptb == DeploymentDescriptor.PROVIDER_JAVA) {
        out.println ("<td>Provider Class</td>");
        out.println ("<td>" + dd.getProviderClass()+ "</td>");
        out.println ("</tr>");
        out.println ("<tr>");
        out.println ("<td>Use Static Class</td>");
        out.println ("<td>" + dd.getIsStatic()+ "</td>");
      } else {
        out.println ("<td>Scripting Language</td>");
        out.println ("<td>" + dd.getScriptLanguage () + "</td>");
        out.println ("</tr>");
        out.println ("<tr>");
        if (ptb == DeploymentDescriptor.PROVIDER_SCRIPT_FILE) {
  	out.println ("<td>Filename</td>");
  	out.println ("<td>" + dd.getScriptFilenameOrString () + "</td>");
        } else {
  	out.println ("<td>Script</td>");
  	out.println ("<td><pre>" + dd.getScriptFilenameOrString () +
  		     "</pre></td>");
        }
      }
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>Methods</td>");
      out.print ("<td>");
      String[] m = dd.getMethods ();
      for (int i = 0; i < m.length; i++) {
        out.print (m[i]);
        if (i < m.length-1) {
  	out.print (", ");
        }
      }
      out.println ("</td>");
      out.println ("</tr>");
      out.println ("<tr>");
      out.println ("<td>Type Mappings</td>");
      out.println ("<td>");
      TypeMapping[] mappings = dd.getMappings();
      if (mappings != null) {
        for (int i = 0; i < mappings.length; i++) {
  	out.print (mappings[i]);
  	if (i < mappings.length-1) {
  	  out.print ("<br>");
  	} else {
  	  break;
  	}
        }
      }
      out.println ("</td>");
      out.println ("</tr>");
      out.println ("</table>");
    }
  %>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/soapadmin.gif
  
  	<<Binary file>>
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/toc.html
  
  Index: toc.html
  ===================================================================
  
  <body bgcolor='lightgreen'>
  <a href="list.jsp" target="data"><img src="list.gif"/></a>
  <p/>
  <a href="deploy.jsp" target="data"><img src="deploy.gif"/></a><br/>
  <p/>
  <a href="undeploy.jsp" target="data"><img src="undeploy.gif"/></a><br/>
  </body>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/undeploy.gif
  
  	<<Binary file>>
  
  
  1.1                  xml-soap/java/src/org/apache/soap/server/undeploy.jsp
  
  Index: undeploy.jsp
  ===================================================================
  <%@ page import="org.apache.soap.*" %>
  <%@ page import="org.apache.soap.server.*" %>
  
  <!-- get the serviceManager object -->
  <jsp:useBean id="serviceManager" 
               class="org.apache.soap.server.ServiceManager"
               scope="application">
  </jsp:useBean>
  
  <h1>Un-Deploy a Service</h1>
  
  <% 
  String id = request.getParameter ("id");
  if (id == null) {
    String[] serviceNames = serviceManager.list ();
    if (serviceNames.length == 0) {
      out.println ("<p>Sorry, there are no services currently deployed.</p>");
    } else {
      out.println ("<p>Select the service to be undeployed:</p>");
      %>
      <ul>
      <%
      for (int i = 0; i < serviceNames.length; i++) {
        id = serviceNames[i];
      %>
        <li><a href="undeploy.jsp?id=<%=id%>"><%= id%></li>
      <%
      }
      %>
      </ul>
      <%
    }
  } else {
    try {
      DeploymentDescriptor dd = serviceManager.undeploy (id);
      out.println ("OK, service named '" + id + "' undeployed successfully!");
    } catch (SOAPException e) {
      out.println ("Ouch, coudn't undeploy service '" + id + "' because: ");
      e.getMessage ();
    }
  }
  %>
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/transport/SOAPTransport.java
  
  Index: SOAPTransport.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.transport;
  
  import java.net.URL;
  import java.io.BufferedReader;
  import java.util.Hashtable;
  import org.apache.soap.*;
  import org.apache.soap.encoding.*;
  
  /**
   * This interface is an abstraction of the transport layer that's carrying
   * the messages.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public interface SOAPTransport {
    /**
     * This method is used to request that an envelope be sent.
     *
     * @param sendTo the URL to send the envelope to
     * @param action the SOAPAction header field value
     * @param headers any other header fields to go to as protocol headers
     * @param env the envelope to send
     * @param smr the XML<->Java type mapping registry (passed on)
     *
     * @exception SOAPException with appropriate reason code if problem
     */
    public void send (URL sendTo, String action, Hashtable headers,
                      Envelope env, SOAPMappingRegistry smr)
      throws SOAPException;
  
    /**
     * Return a buffered reader to receive back the response to whatever
     * was sent to whatever.
     *
     * @return a reader to read the results from or null if that's not
     *         possible.
     */
    public BufferedReader receive ();
  
    /**
     * Return access to headers generated by the protocol.
     * 
     * @return a hashtable containing all the headers
     */
    public Hashtable getHeaders ();
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/transport/http/SOAPHTTPConnection.java
  
  Index: SOAPHTTPConnection.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.transport.http;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.net.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.*;
  import org.apache.soap.encoding.*;
  import org.apache.soap.transport.*;
  
  /**
   * <code>SOAPHTTPConnection</code> is an implementation of the
   * <code>SOAPTransport</code> interface for <em>HTTP</em>.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class SOAPHTTPConnection implements SOAPTransport
  {
    private BufferedReader responseReader;
    private Hashtable responseHeaders;
  
    /**
     * This method is used to request that an envelope be posted to the
     * given URL. The response (if any) must be gotten by calling the
     * receive() function.
     *
     * @param sendTo the URL to send the envelope to
     * @param action the SOAPAction header field value
     * @param headers any other header fields to go to as protocol headers
     * @param env the envelope to send
     * @param smr the XML<->Java type mapping registry (passed on)
     *
     * @exception SOAPException with appropriate reason code if problem
     */
    public void send (URL sendTo, String action, Hashtable headers,
  		    Envelope env,
  		    SOAPMappingRegistry smr) throws SOAPException {
      try {
        StringWriter payloadSW = new StringWriter ();
        env.marshall (payloadSW, smr);
  
        if (headers == null) {
          headers = new Hashtable ();
        }
        headers.put (Constants.HEADER_SOAP_ACTION, 
  		   (action != null) ? ('\"' + action + '\"') : "");
  
        HTTPUtils.Response response = HTTPUtils.post (sendTo, headers,
                 Constants.HEADERVAL_CONTENT_TYPE,
                 payloadSW.toString ());
  
        responseReader = response.content;
        responseHeaders = response.headers;
      } catch (IllegalArgumentException e) {
        throw new SOAPException (Constants.FAULT_CODE_CLIENT, e.getMessage(), e);
      } catch (IOException e) {
        throw new SOAPException (Constants.FAULT_CODE_CLIENT, e.getMessage(), e);
      }
    }
  
    /**
     * Return a buffered reader to receive back the response to whatever
     * was sent to whatever.
     *
     * @return a reader to read the results from or null if that's not
     *         possible.
     */
    public BufferedReader receive () {
      return responseReader;
    }
  
    /**
     * Return access to headers generated by the protocol.
     * 
     * @return a hashtable containing all the headers
     */
    public Hashtable getHeaders () {
      return responseHeaders;
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/transport/smtp/POP3StatusListener.java
  
  Index: POP3StatusListener.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.transport.smtp;
  
  import com.ibm.network.mail.base.*;
  import com.ibm.network.mail.pop3.event.*;
  
  /**
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class POP3StatusListener implements StatusListener {
    public void operationComplete (StatusEvent e) {
      System.err.println ("DONE: " + e.getStatusString ());
    }
  
    public void processStatus (StatusEvent e) {
      System.err.println ("Status update: " + e.getStatusString ());
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/transport/smtp/SMTPConstants.java
  
  Index: SMTPConstants.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.transport.smtp;
  
  public class SMTPConstants {
    public static String SMTP_HEADER_SUBJECT = "Subject";
    public static String SMTP_HEADER_TO = "To";
    public static String SMTP_HEADER_FROM = "From";
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/transport/smtp/SMTPUtils.java
  
  Index: SMTPUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.transport.smtp;
  
  /**
   * Various SMTP utilities.
   * 
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class SMTPUtils {
    /**
     * This method takes an SMTP header line like from say "To:" header and 
     * extracts the actual email address in there. If there are multiple
     * addresses there, then the first one is returned. This method
     * should follow the RFC822 guidelines on how an email address is
     * encoded.
     *
     * @param header the header line (without the header name - i.e., just
     *               the stuff after the first ':').
     * @return the email address in the header or null if can't figure it out
     */
    public static String getAddressFromAddressHeader (String header) {
      // if there's a '<' char then read the addr upto the next '>'
      int ltIndex = header.indexOf ('<');
      if (ltIndex != -1) {
        String rest = header.substring (ltIndex + 1);
        int rtIndex = rest.indexOf ('>');
        if (rtIndex != -1) {
  	      return rest.substring (0, rtIndex);
        } else {
  	      return null; // malformed?
        }
      } else {
        return header;
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/transport/smtp/SOAPSMTPConnection.java
  
  Index: SOAPSMTPConnection.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.transport.smtp;
  
  import java.io.*;
  import java.net.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  import org.apache.soap.util.xml.*;
  import org.apache.soap.Envelope;
  import org.apache.soap.SOAPException;
  import org.apache.soap.encoding.*;
  import org.apache.soap.transport.*;
  import org.apache.soap.rpc.*;
  
  import com.ibm.network.mail.base.*;
  
  /**
   * <code>SOAPSMTPConnection</code> is an implementation of the
   * <code>SOAPTransport</code> interface for <em>SMTP</em>.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class SOAPSMTPConnection implements SOAPTransport {
    private String fromAddr;
    private String subject;
    private Object waitObject = new Object ();
    private long popPollDelay;
    private boolean responseReceived = false;
    private Hashtable responseHeaders = new Hashtable ();
    private BufferedReader responseReader = null;
    com.ibm.network.mail.smtp.protocol.CoreProtocolBean smtpBean =
      new com.ibm.network.mail.smtp.protocol.CoreProtocolBean ();
    com.ibm.network.mail.pop3.protocol.CoreProtocolBean pop3Bean =
      new com.ibm.network.mail.pop3.protocol.CoreProtocolBean ();
  
    /**
     * Constructor: sets up this SMTP connection for sending and 
     * receiving a SOAP envelope via SMTP and POP3, respectively.
     *
     * @param fromAddr the sender's address
     * @param subject subject of the email message
     * @param smtpServer the SMTP server to use to send
     * @param popPollDelay the number of millis to sleep between response polls
     * @param popServer hostname of POP3 server to receive from
     * @param popLogin login ID to receive mail at
     * @param popPassword password for login
     */
    public SOAPSMTPConnection (String fromAddr, String subject, 
  			     String smtpServer, long popPollDelay,
  			     String popServer, String popLogin,
  			     String popPassword) {
      this.fromAddr = fromAddr;
      this.subject = subject;
  
      // set up send side
      smtpBean.setSmtpServerHost (smtpServer);
      smtpBean.addStatusListener (
        new com.ibm.network.mail.smtp.event.StatusListener () {
          public void operationComplete (
              com.ibm.network.mail.smtp.event.StatusEvent e) {
  	  System.err.println ("DONE: " + e.getStatusString ());
  	  synchronized (waitObject) {
  	    waitObject.notify ();
  	  }
  	}
  	
  	public void processStatus (
              com.ibm.network.mail.smtp.event.StatusEvent e) {
  	  System.err.println ("Status update: " + e.getStatusString ());
  	}
        }
      );
  
      // set up receive side
      pop3Bean.setPOP3ServerHost (popServer);
      pop3Bean.setUserOptions(/* popLoginName */ popLogin,
  			    /* password */ popPassword,
  			    /* leaveMessagesOnServer */ false,
  			    /* rememberPassword */ false);
      pop3Bean.addMessageListener (
        new com.ibm.network.mail.pop3.event.MessageListener () {
          public void messageReceived (
              com.ibm.network.mail.pop3.event.MessageEvent me) {
  	  /* extract the stuff from the POP message received */
  	  MimeMessage msg = me.getMessage ();
  	  String subj = msg.getHeader (SMTPConstants.SMTP_HEADER_SUBJECT);
  	  if (subj != null) {
  	    responseHeaders.put (SMTPConstants.SMTP_HEADER_SUBJECT, subj);
  	  }
  	  String soapAction = 
  	    msg.getHeader (org.apache.soap.Constants.HEADER_SOAP_ACTION);
  	  if (soapAction != null) {
  	    responseHeaders.put (org.apache.soap.Constants.HEADER_SOAP_ACTION,
  				 soapAction);
  	  }
  	  String to = msg.getHeader (SMTPConstants.SMTP_HEADER_TO);
  	  if (to != null) {
  	    responseHeaders.put (SMTPConstants.SMTP_HEADER_TO, to);
  	  }
  	  String from = msg.getHeader (SMTPConstants.SMTP_HEADER_FROM);
  	  if (from != null) {
  	    responseHeaders.put (SMTPConstants.SMTP_HEADER_FROM, from);
  	  }
  	  MimeBodyPart mbp = (MimeBodyPart) msg.getContent ();
  	  byte[] ba = (byte[]) mbp.getContent ();
  	  String baStr = new String (ba);
  	  responseReader = new BufferedReader (new StringReader (baStr));
  	  responseReceived = true;
  	}
        }
      );
      pop3Bean.addStatusListener (new POP3StatusListener ());
    }
  
    /**
     * This method is used to request that an envelope be sent.
     *
     * @param sendTo the URL to send the envelope to ("mailto:xxx@yyy")
     * @param action the SOAPAction header field value
     * @param headers any other header fields to go to as protocol headers
     *        [IGNORED right now]
     * @param env the envelope to send
     * @param smr the XML<->Java type mapping registry (passed on)
     *
     * @exception SOAPException with appropriate reason code if problem
     */
    public void send (URL toAddr, String actionURI, Hashtable headers,
  		    Envelope env,
  		    SOAPMappingRegistry smr) throws SOAPException {
      MimeMessage msg = new MimeMessage();
  
      MimeBodyPart mbp = new MimeBodyPart ();
      StringWriter sw = new StringWriter();
      try {
        env.marshall (sw, smr);
      } catch (IOException e) {
        e.printStackTrace ();
      }
      mbp.setContent (sw.toString (), "text/xml");
      mbp.setEncoding (MimePart.SEVENBIT);
      mbp.setDisposition (MimePart.INLINE);
      msg.setContent (mbp, "");
  
      msg.addHeader ("Subject", subject);
      msg.addHeader ("SOAPAction", actionURI);
      msg.addHeader ("From", fromAddr);
      msg.addRecipients (MimeMessage.TO, 
  		       new InternetAddress[] {
                           new InternetAddress (toAddr.getFile ())
  		       });
  
      smtpBean.sendMessage (msg);
  
      try {
        synchronized (waitObject) {
          waitObject.wait ();
        }
      } catch (Exception e) {
        e.printStackTrace ();
      }
    }
  
    /**
     * Return a buffered reader to receive back the response to whatever
     * was sent to whatever. This does a blocking wait until a response
     * is received .. don't do it lightly. Should take into account
     * timeouts and such in the future.
     *
     * @return a reader to read the results from or null if that's not
     *         possible.
     */
    public BufferedReader receive () {
      responseReceived = false;
      while (!responseReceived) {
        try {
  	if (pop3Bean.isReady ()) {
  	  System.err.println ("SOAPSMTPConnection: Polling for response ..");
  	  pop3Bean.receiveMessage ();
  	  if (responseReceived) {
  	    break;
  	  }
  	}
          Thread.sleep (popPollDelay);
        } catch (Exception e) {
          e.printStackTrace ();
        }
      }
      return responseReader;
    }
  
    /**
     * Return access to headers generated by the protocol.
     * 
     * @return a hashtable containing all the headers
     */
    public Hashtable getHeaders () {
      return responseHeaders;
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/Bean.java
  
  Index: Bean.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util;
  
  /**
   * A <em>Bean</em> is the class used to represent a bean: it holds a 
   * type and a value. This is needed because otherwise we can't represent 
   * the types of null-valued beans (or primitives) correctly. This was
   * originally in the BML player.
   *
   * @author   Sanjiva Weerawarana
   */
  public class Bean {
    // type of this bean
    public Class type;
  
    // its current value (mebbe null)
    public Object value;
  
    public Bean (Class type, Object value) {
      this.type = type;
      this.value = value;
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/DOMUtils.java
  
  Index: DOMUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util;
  
  import org.w3c.dom.*;
  
  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;
    }
  
    /**
     * 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.
     *
     * @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 = tempEl.getAttributeNS (NS_URI_XMLNS, prefix);
  
        if (namespaceURI != null)
        {
          return namespaceURI;
        }
        else
        {
          tempNode = tempEl.getParentNode ();
        }
      }
  
      return null;
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/IOUtils.java
  
  Index: IOUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: IOUtils.java,v 1.1 2000/05/22 00:04:19 rubys Exp $ */
  
  package org.apache.soap.util;
  
  import java.io.*;
  
  /**
   * This file is a collection of input/output utilities.
   * 
   * @version  $Revision: 1.1 $
   * @author   Sanjiva Weerawarana
   * @author   Matthew J. Duftler
   */
  public class IOUtils {
    // debug flag - generates debug stuff if true
    static boolean debug = false;
  
    //////////////////////////////////////////////////////////////////////////
  
    public static String getStringFromReader (Reader reader) throws IOException {
      BufferedReader bufIn = new BufferedReader(reader);
      StringWriter   swOut = new StringWriter();
      PrintWriter    pwOut = new PrintWriter(swOut);
      String         tempLine;
  
      while ((tempLine = bufIn.readLine()) != null) {
        pwOut.println(tempLine);
      }
  
      pwOut.flush();
  
      return swOut.toString();
    }
  }
  
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/IndentWriter.java
  
  Index: IndentWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: IndentWriter.java,v 1.1 2000/05/22 00:04:19 rubys Exp $ */
  
  package org.apache.soap.util;
  
  import java.io.*;
  
  /**
   * An <code>IndentWriter</code> object behaves the same as a
   * <code>PrintWriter</code> object, with the additional capability
   * of being able to print strings that are prepended with a specified
   * amount of spaces.
   *
   * @version  $Revision: 1.1 $
   * @author Matthew J. Duftler
   */
  public class IndentWriter extends PrintWriter
  {
    /**
     * Forwards its arguments to the <code>PrintWriter</code> constructor
     * with the same signature.
     */
    public IndentWriter(OutputStream out)
    {
      super(out);
    }
  
    /**
     * Forwards its arguments to the <code>PrintWriter</code> constructor
     * with the same signature.
     */
    public IndentWriter(OutputStream out, boolean autoFlush)
    {
      super(out, autoFlush);
    }
  
    /**
     * Forwards its arguments to the <code>PrintWriter</code> constructor
     * with the same signature.
     */
    public IndentWriter(Writer out)
    {
      super(out);
    }
  
    /**
     * Forwards its arguments to the <code>PrintWriter</code> constructor
     * with the same signature.
     */
    public IndentWriter(Writer out, boolean autoFlush)
    {
      super(out, autoFlush);
    }
  
    /**
     * Print the text (indented the specified amount) without inserting a linefeed.
     *
     * @param numberOfSpaces the number of spaces to indent the text.
     * @param text the text to print.
     */
    public void print(int numberOfSpaces, String text)
    {
      super.print(StringUtils.getChars(numberOfSpaces, ' ') + text);
    }
  
    /**
     * Print the text (indented the specified amount) and insert a linefeed.
     *
     * @param numberOfSpaces the number of spaces to indent the text.
     * @param text the text to print.
     */
    public void println(int numberOfSpaces, String text)
    {
      super.println(StringUtils.getChars(numberOfSpaces, ' ') + text);
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: JavaUtils.java,v 1.1 2000/05/22 00:04:19 rubys Exp $ */
  
  package org.apache.soap.util;
  
  import java.io.IOException;
  
  public class JavaUtils
  {
    // Debug flag - generates debug stuff if true.
    private static boolean debug = false;
  
    // Temporarily copied from JavaEngine...
    private static boolean cantLoadCompiler=false; // One-time flag for following
  
    // ADDED BY JKESS; callers want control over the -g option.
    public static void setDebug(boolean newDebug)
    {
      debug=newDebug;
    }
  
    public static boolean JDKcompile(String fileName, String classPath)
    {
      if (debug)
      {
        System.err.println ("JavaEngine: Compiling " + fileName);
        System.err.println ("JavaEngine: Classpath is " + classPath);
      }
      
      String option = debug ? "-g" : "-O";
  
      if(!cantLoadCompiler)
        {
    String args[] = {
      option,
      "-classpath",
      classPath,
      fileName
    };
    try
      {
        return new sun.tools.javac.Main(System.err, "javac").compile(args);
      }
    catch (Throwable th)
      {
        System.err.println("WARNING: Unable to load Java 1.1 compiler.");
        System.err.println("\tSwitching to command-line invocation.");
        cantLoadCompiler=true;
      }
        }
      
      // Can't load javac; try exec'ing it.
      String args[] = {
        "javac",
        option,
        "-classpath",
        classPath,
        fileName
      };
      try
        {
    Process p=java.lang.Runtime.getRuntime().exec(args);
    p.waitFor();
    return(p.exitValue()!=0);
        }
      catch(IOException e)
        {
    System.err.println("ERROR: IO exception during exec(javac).");
        }
      catch(SecurityException e)
        {
    System.err.println("ERROR: Unable to create subprocess to exec(javac).");
        }
      catch(InterruptedException e)
        {
    System.err.println("ERROR: Wait for exec(javac) was interrupted.");
        }
      return false;
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/MethodUtils.java
  
  Index: MethodUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util;
  
  import java.util.*;
  import java.io.*;
  import java.beans.*;
  import java.lang.reflect.*;
  
  /**
   * This file is a collection of reflection utilities for dealing with
   * methods and constructors.
   * 
   * @author   Sanjiva Weerawarana
   * @author   Joseph Kesselman
   */
  public class MethodUtils {
  
    //////////////////////////////////////////////////////////////////////////
  
    /**
     * Search for entry point, per  Java Language Spec 1.0
     * as amended, verified by comparison against compiler behavior.
     *
     * @param targetClass Class object for the class to be queried.
     * @param methodName  Name of method to invoke, or null for constructor.
     *                    Only Public methods will be accepted.
     * @param argTypes    Classes of intended arguments.  Note that primitives
     *                    must be specified via their TYPE equivalents, 
     *                    rather than as their wrapper classes -- Integer.TYPE
     *                    rather than Integer. "null" may be passed in as an
     *                    indication that you intend to invoke the method with
     *                    a literal null argument and therefore can accept
     *                    any object type in this position.
     * @param isStaticReference  If true, and if the target is a Class object,
     *                    only static methods will be accepted as valid matches.
     *
     * @return a Method or Constructor of the appropriate signature
     *
     * @exception SecurityException     if security violation
     * @exception NoSuchMethodException if no such method
     */
    static private Object getEntryPoint(Class targetClass,
                                        String methodName,
                                        Class[] argTypes,
                                        boolean isStaticReference) 
         throws SecurityException, NoSuchMethodException
    {
      // 15.11.1: OBTAIN STARTING CLASS FOR SEARCH
      Object m=null;
      
      // 15.11.2 DETERMINE ARGUMENT SIGNATURE
      // (Passed in as argTypes array.)
      
      // Shortcut: If an exact match exists, return it.
      try {
        if(methodName!=null)
          {
            m=targetClass.getMethod (methodName, argTypes);
            if(isStaticReference &&
               !Modifier.isStatic(entryGetModifiers(m)) )
              {
                throw 
                  new NoSuchMethodException (callToString (targetClass,
                                                           methodName,
                                                           argTypes,
                                                           isStaticReference)+
                                             " resolved to instance " + m);
              }
            return m;
          }
        else
          return targetClass.getConstructor (argTypes);
            
      } catch (NoSuchMethodException e) {
        // no-args has no alternatives!
        if(argTypes==null || argTypes.length==0)
        {
          throw 
            new NoSuchMethodException (callToString (targetClass,
                                                     methodName,
                                                     argTypes,
                                                     isStaticReference)+
                                       " not found.");
        }
        // Else fall through.
      }
      
      // Well, _that_ didn't work. Time to search for the Most Specific
      // matching function. NOTE that conflicts are possible!
      
      // 15.11.2.1 ACCESSIBLE: We apparently need to gather from two
      // sources to be sure we have both instance and static methods.
      Object[] methods;
      if(methodName!=null)
        {
          methods=targetClass.getMethods();
        }
      else
        {
          methods=targetClass.getConstructors();
        }
      if(0==methods.length)
        {
          throw new NoSuchMethodException("No methods!");
        }
  
      MoreSpecific best=new MoreSpecific();
      for(int i=0;i<methods.length;++i)
        {
          Object mi=methods[i];
          if (
              // 15.11.2.1 ACCESSIBLE: Method is public.
              Modifier.isPublic(entryGetModifiers(mi))
              &&
              // 15.11.2.1 APPLICABLE: Right method name (or c'tor)
              (methodName==null || entryGetName(mi).equals(methodName) )
              &&
              // 15.11.2.1 APPLICABLE: Parameters match arguments
              areMethodConvertable(entryGetParameterTypes(mi),argTypes)
               )
            // 15.11.2.2 MORE SPECIFIC displace less specific.
            best.addItem(mi);
        }
  
      // May throw NoSuchMethodException; we pass in info needed to
      // create a useful exception
      m=best.getMostSpecific(targetClass,methodName,argTypes,isStaticReference);
    
      // 15.11.3 APPROPRIATE: Class invocation can call only static
      // methods. Note that the defined order of evaluation permits a
      // call to be resolved to an inappropriate method and then
      // rejected, rather than finding the best of the appropriate
      // methods.
      //
      // Constructors are never static, so we don't test them.
      if(m==null)
        {
          throw new NoSuchMethodException (callToString(targetClass,
                                                        methodName,
                                                        argTypes,
                                                        isStaticReference)+
                                           " -- no signature match");
        }
  
      if( methodName!=null &&
          isStaticReference &&
          !Modifier.isStatic(entryGetModifiers(m)) )
        {
          throw new NoSuchMethodException (callToString(targetClass,
                                                        methodName,
                                                        argTypes,
                                                        isStaticReference)+
                                           " resolved to instance: "+m);
        }
  
      return m;
    }
  
    
    /** Internal subroutine for getEntryPoint(): Format arguments as a
        string describing the function being searched for. Used in
        verbose exceptions. */
    private static String callToString(Class targetClass,String methodName,
                                      Class[] argTypes,boolean isStaticReference)
    {
      StringBuffer buf = new StringBuffer();
      if(isStaticReference)
        buf.append("static ");
      buf.append(StringUtils.getClassName(targetClass));
      if(methodName!=null)
        buf.append(".").append(methodName);
      buf.append("(");
      if (argTypes != null && argTypes.length>0) {
        if(false)
          {
            // ????? Sanjiva has an ArrayToString method. Using it would save
            // a few bytes, at cost of giving up some reusability.
          }
        else
          {
            buf.append(StringUtils.getClassName(argTypes[0]));
            for (int i = 1; i < argTypes.length; i++) {
              buf.append(",").append(StringUtils.getClassName(argTypes[i]));
            }
          }
      }
      else
        buf.append("[none]");
      buf.append(")");
      return buf.toString();
    }
  
    /** Determine whether a given method parameter type can accept
      arguments of another type.
  
      parm: The type given in the method's signature.
      arg: The type we want to pass in.
  
      Legal METHOD CONVERSIONS (5.3) are Identity, Widening Primitive
      Conversion, or Widening Reference Conversion. NOTE that this is a
      subset of the legal ASSIGNMENT CONVERSIONS (5.2) -- in particular,
      we can't implicitly narrow int to byte, short or char.
  
      SPECIAL CASE: In order to permit invoking methods with literal
      "null" values, setting the arg Class to null will be taken as a
      request to match any Class type. POSSIBLE PROBLEM: This may match
      a primitive type, which really should not accept a null value... but
      I'm not sure how best to distinguish those, short of enumerating them
      */
    static private boolean isMethodConvertable(Class parm, Class arg)
    {
      if (parm.equals(arg))       // If same class, short-circuit now!
        return true;
  
      // Accept any type EXCEPT primitives (which can't have null values).
      if (arg == null)
      {
        return !parm.isPrimitive();
      }
  
      // Arrays are convertable if their elements are convertable
      // ????? Does this have to be done before isAssignableFrom, or
      // does it successfully handle arrays of primatives?
      while(parm.isArray())
        {
          if(!arg.isArray())
            return false;         // Unequal array depth
          else
            {
              parm=parm.getComponentType();
              arg=arg.getComponentType();
            }
        }
      if(arg.isArray())
        return false;             // Unequal array depth
      
      // Despite its name, the 1.1.6 docs say that this function does
      // NOT return true for all legal ASSIGNMENT CONVERSIONS
      // (5.2):
      //   "Specifically, this method tests whether the type
      //   represented by the specified class can be converted
      //   to the type represented by this Class object via
      //   an identity conversion or via a widening reference
      //   conversion."
      if(parm.isAssignableFrom(arg))
        return true;
  
      // That leaves us the Widening Primitives case. Four possibilities:
      // void (can only convert to void), boolean (can only convert to boolean),
      // numeric (which are sequenced) and char (which inserts itself into the
      // numerics by promoting to int or larger)
  
      if(parm.equals(Void.TYPE) || parm.equals(Boolean.TYPE) ||
         arg.equals(Void.TYPE) || arg.equals(Boolean.TYPE))
        return false;
      
      Class[] primTypes={ Character.TYPE, Byte.TYPE, Short.TYPE, Integer.TYPE,
                          Long.TYPE, Float.TYPE, Double.TYPE };
      int parmscore,argscore;
      
      for(parmscore=0;parmscore<primTypes.length;++parmscore)
        if (parm.equals(primTypes[parmscore]))
          break;
      if(parmscore>=primTypes.length)
        return false;             // Off the end
      
      for(argscore=0;argscore<primTypes.length;++argscore)
        if (arg.equals(primTypes[argscore]))
          break;
      if(argscore>=primTypes.length)
        return false;             // Off the end
      
      // OK if ordered AND NOT char-to-smaller-than-int
      return (argscore<parmscore && (argscore!=0 || parmscore>2) );
    }
  
    
    /** Determine whether a given type can accept assignments of another
      type. Note that class.isAssignable() is _not_ a complete test!
      (This method is not needed by getMethod() or getConstructor(), but
      is provided as a convenience for other users.)
      
      parm: The type given in the method's signature.
      arg: The type we want to pass in.
  
      Legal ASSIGNMENT CONVERSIONS (5.2) are METHOD CONVERSIONS (5.3)
      plus implicit narrowing of int to byte, short or char.  */
    static private boolean isAssignmentConvertable(Class parm,Class arg)
    {
      return
        (arg.equals(Integer.TYPE) &&
         (parm.equals(Byte.TYPE) ||
          parm.equals(Short.TYPE) ||
          parm.equals(Character.TYPE)
           )
          ) ||
        isMethodConvertable(parm,arg);
    }
  
  
    /** Convenience method: Test an entire parameter-list/argument-list pair
      for isMethodConvertable(), qv. 
      */
    static private boolean areMethodConvertable(Class[] parms,Class[] args)
    {
      if(parms.length!=args.length)
        return false;
      
      for(int i=0;i<parms.length;++i)
        if(!isMethodConvertable(parms[i],args[i]))
          return false;
      
      return true;
    }
  
    /** Internal Class for getEntryPoint(). Implements 15.11.2.2 MORE
      SPECIFIC rules.
  
      Retains a list of methods (already known to match the
      arguments). As each method is added, we check against past entries
      to determine which if any is "more specific" -- defined as having
      _all_ its arguments (not just a preponderance) be
      method-convertable into those of another. If such a relationship
      is found, the more-specific method is retained and the
      less-specific method is discarded. At the end, if this has yielded
      a single winner it is considered the Most Specific Method and
      hence the one that should be invoked.  Otherwise, a
      NoSuchMethodException is thrown.
      
      PERFORMANCE VERSUS ARCHITECTURE: Arguably, this should "have-a"
      Vector. But the code is 6% smaller, and possibly faster, if we
      code it as "is-a" Vector. Since it's an inner class, nobody's
      likely to abuse the privilage.
      
      Note: "Static" in the case of an inner class means "Does not
      reference instance data in the outer class", and is required since
      our caller is a static method. */
    private static class MoreSpecific
    extends Vector
    {
      /** Submit an entry-point to the list. May be discarded if a past
        entry is more specific, or may cause others to be discarded it
        if is more specific.
  
        newEntry: Method or Constructor under consideration.
        */
      void addItem (Object newEntry)
      {
        if(size()==0)
          addElement(newEntry);
        else
          {
            Class[] newargs=entryGetParameterTypes(newEntry);
            boolean keep=true;
            for (Enumeration e = elements();
                 keep & e.hasMoreElements() ;
                  )
              {
                Object oldEntry=e.nextElement();
                // CAVEAT: Implicit references to enclosing class!
                Class[] oldargs=entryGetParameterTypes(oldEntry);
                if(areMethodConvertable(oldargs,newargs))
                  removeElement(oldEntry); // New more specific; discard old
                else if(areMethodConvertable(newargs,oldargs))
                  keep=false;     // Old more specific; discard new
                // Else they're tied. Keep both and hope someone beats both.
              }
            if(keep)
              addElement(newEntry);
          }
      }
  
      /** Obtain the single Most Specific entry-point. If there is no clear
        winner, or if the list is empty, throw NoSuchMethodException.
  
        Arguments describe the call we were hoping to resolve. They are
        used to throw a nice verbose exception if something goes wrong.
        */
      Object getMostSpecific(Class targetClass,String methodName,
                             Class[] argTypes,boolean isStaticReference)
           throws NoSuchMethodException
      {
        if(size()==1)
          return firstElement();
        if(size()>1)
          {
            StringBuffer buf=new StringBuffer();
            Enumeration e=elements();
            buf.append(e.nextElement());
            while(e.hasMoreElements())
              buf.append(" and ").append(e.nextElement());
            throw new NoSuchMethodException (callToString(targetClass,
                                                          methodName,
                                                          argTypes,
                                                          isStaticReference)+
                                             " is ambiguous. It matches "+
                                             buf.toString());
          }
        return null;
      }
    }
  
    // The common lookup code would be much easier if Method and
    // Constructor shared an "EntryPoint" Interface. Unfortunately, even
    // though their APIs are almost identical, they don't. These calls
    // are a workaround...  at the cost of additional runtime overhead
    // and some extra bytecodes.
    //
    // (A JDK bug report has been submitted requesting that they add the
    // Interface; it would be easy, harmless, and useful.)
  
    /** Utility function: obtain common data from either Method or
        Constructor. (In lieu of an EntryPoint interface.) */
    static String entryGetName(Object entry)
    {
      return (entry instanceof Method)
        ? ((Method)entry).getName()
        : ((Constructor)entry).getName();
    }
    /** Utility function: obtain common data from either Method or
        Constructor. (In lieu of an EntryPoint interface.) */
    static int entryGetModifiers(Object entry)
    {
      return (entry instanceof Method)
        ? ((Method)entry).getModifiers()
        : ((Constructor)entry).getModifiers();
    }
    /** Utility function: obtain common data from either Method or
        Constructor. (In lieu of an EntryPoint interface.) */
    static Class[] entryGetParameterTypes(Object entry)
    {
      return (entry instanceof Method)
        ? ((Method)entry).getParameterTypes()
        : ((Constructor)entry).getParameterTypes();
    }
    /** Utility function: obtain common data from either Method or
        Constructor. (In lieu of an EntryPoint interface.) */
    static String entryToString(Object entry)
    {
      return (entry instanceof Method)
        ? ((Method)entry).toString()
        : ((Constructor)entry).toString();
    }
  
    //////////////////////////////////////////////////////////////////////////
  
    /**
     * Class.getMethod() finds only the entry point (if any) _exactly_
     * matching the specified argument types. Our implmentation can
     * decide between several imperfect matches, using the same search
     * algorithm as the Java compiler.
     *
     * This version emulates the compiler behavior by allowing lookup to
     * be performed against either a class or an instance -- classname.foo()
     * must be a static method call, instance.foo() can invoke either static
     * or instance methods.
     *
     * @param target     object on which call is to be made
     * @param methodName name of method I'm lookin' for
     * @param argTypes   array of argument types of method
     *
     * @return the desired method
     *
     * @exception SecurityException     if security violation
     * @exception NoSuchMethodException if no such method
     */
    static public Method getMethod(Object target,String methodName,
                                   Class[] argTypes)
         throws SecurityException, NoSuchMethodException
    {
      boolean staticRef=target instanceof Class;
      return getMethod( staticRef ? (Class)target : target.getClass(),
                        methodName,argTypes,staticRef);
    }
  
    //////////////////////////////////////////////////////////////////////////
  
    /* Class.getMethod() finds only the entry point (if any) _exactly_
      matching the specified argument types. Our implmentation can
      decide between several imperfect matches, using the same search
      algorithm as the Java compiler.
  
      This version more closely resembles Class.getMethod() -- we always
      ask the Class for the method. It differs in testing for
      appropriateness before returning the method; if the query is
      being made via a static reference, only static methods will be
      found and returned. */
    static public Method getMethod(Class target,String methodName,
                                   Class[] argTypes,boolean isStaticReference)
         throws SecurityException, NoSuchMethodException
    {
      return (Method)getEntryPoint(target,methodName,argTypes,isStaticReference);
    }
  
    //////////////////////////////////////////////////////////////////////////
  
    /** Class.getConstructor() finds only the entry point (if any)
      _exactly_ matching the specified argument types. Our implmentation
      can decide between several imperfect matches, using the same
      search algorithm as the Java compiler.
  
      Note that all constructors are static by definition, so
      isStaticReference is true.
  
      @exception NoSuchMethodException if constructor not found.
      */
    static public Constructor getConstructor(Class targetClass, Class[] argTypes)
         throws SecurityException, NoSuchMethodException
    {
      return (Constructor) getEntryPoint(targetClass,null,argTypes,true);
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/ObjInfo.java
  
  Index: ObjInfo.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: ObjInfo.java,v 1.1 2000/05/22 00:04:19 rubys Exp $ */
  
  package org.apache.soap.util;
  
  /**
   * An <code>ObjInfo</code> object is used by a compiler to track the name and
   * type of a bean.
   * 
   * @version  $Revision: 1.1 $
   * @author   Matthew J. Duftler
   */
  public class ObjInfo
  {
    static private String QUOTE_CHARS = "\'\"",
                          EXEC_CHARS  = "(=";
           public  String objName;
           public  Class  objClass;
  
    public ObjInfo(Class objClass, String objName)
    {
      this.objClass = objClass;
      this.objName  = objName;
    }
  
    public boolean isExecutable()
    {
      char[]  chars            = objName.toCharArray();
      char    openingChar      = ' ';
      boolean inString         = false,
              inEscapeSequence = false;
  
      for (int i = 0; i < chars.length; i++)
      {
        if (inEscapeSequence)
        {
          inEscapeSequence = false;
        }
        else if (QUOTE_CHARS.indexOf(chars[i]) != -1)
        {
          if (!inString)
          {
            openingChar = chars[i];
            inString = true;
          }
          else
          {
            if (chars[i] == openingChar)
            {
              inString = false;
            }
          }
        }
        else if (EXEC_CHARS.indexOf(chars[i]) != -1)
        {
          if (!inString)
          {
            return true;
          }
        }
        else if (inString && chars[i] == '\\')
        {
          inEscapeSequence = true;
        }
      }
  
      return false;
    }
  
    public boolean isValueReturning()
    {
      return (objClass != void.class && objClass != Void.class);
    }
  
    public String toString()
    {
      return StringUtils.getClassName(objClass) + " " + objName;
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/ObjectRegistry.java
  
  Index: ObjectRegistry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: ObjectRegistry.java,v 1.1 2000/05/22 00:04:19 rubys Exp $ */
  
  package org.apache.soap.util;
  
  import java.util.*;
  
  /**
   * The <em>ObjectRegistry</em> is used to do name-to-object reference lookups.
   * If an <em>ObjectRegistry</em> is passed as a constructor argument, then this
   * <em>ObjectRegistry</em> will be a cascading registry: when a lookup is
   * invoked, it will first look in its own table for a name, and if it's not
   * there, it will cascade to the parent <em>ObjectRegistry</em>.
   * All registration is always local. [??]
   * 
   * @version  $Revision: 1.1 $
   * @author   Sanjiva Weerawarana
   * @author   Matthew J. Duftler
   */
  public class ObjectRegistry {
    Hashtable      reg    = new Hashtable ();
    ObjectRegistry parent = null;
  
    public ObjectRegistry () {
    }
  
    public ObjectRegistry (ObjectRegistry parent) {
      this.parent = parent;
    }
  
    // register an object
    public void register (String name, Object obj) {
      reg.put (name, obj);
    }
  
    // unregister an object (silent if unknown name)
    public void unregister (String name) {
      reg.remove (name);
    }
  
    // lookup an object: cascade up if needed
    public Object lookup (String name) throws IllegalArgumentException {
      Object obj = reg.get (name);
  
      if (obj == null && parent != null) {
        obj = parent.lookup (name);
      }
  
      if (obj == null) {
        throw new IllegalArgumentException ("object '" + name + "' not in registry");
      }
  
      return obj;
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/ScriptSymbolTable.java
  
  Index: ScriptSymbolTable.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: ScriptSymbolTable.java,v 1.1 2000/05/22 00:04:19 rubys Exp $ */
  
  package org.apache.soap.util;
  
  import java.util.Hashtable;
  
  /**
   * An <code>ScriptSymbolTable</code> object is used by a <code>CodeBuffer</code>
   * object to implement nested scopes.
   * 
   * @version  $Revision: 1.1 $
   * @author   Matthew J. Duftler
   */
  class ScriptSymbolTable extends Hashtable
  {
  	private Hashtable parentTable;
  
  	ScriptSymbolTable(Hashtable parentTable)
    {
    	this.parentTable = parentTable;
    }
  
    public synchronized Object get(Object key)
    {
    	Object ret = super.get(key);
  
    	if (ret == null && parentTable != null)
    	  ret = parentTable.get(key);
  
    	return ret;
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/StringUtils.java
  
  Index: StringUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: StringUtils.java,v 1.1 2000/05/22 00:04:19 rubys Exp $ */
  
  package org.apache.soap.util;
  
  import java.io.*;
  import java.util.*;
  import java.net.URL;
  import java.net.MalformedURLException;
  import java.beans.Introspector;
  
  /**
   * Deals with strings (probably need to elaborate some more).
   *
   * @version  $Revision: 1.1 $
   * @author   Matthew J. Duftler
   */
  public class StringUtils
  {
    public static final String lineSeparator =
      System.getProperty("line.separator", "\n");
    public static final String lineSeparatorStr = cleanString(lineSeparator);
  
    // Handles multi-line strings.
    public static String getSafeString(String scriptStr)
    {
      BufferedReader in           = new BufferedReader(new StringReader(scriptStr));
      StringBuffer   strBuf       = new StringBuffer();
      String         tempLine,
                     previousLine = null;
  
      try
      {
        while ((tempLine = in.readLine()) != null)
        {
          if (previousLine != null)
          {
            strBuf.append("\"" + previousLine + lineSeparatorStr + "\" +" +
                          lineSeparator);
          }
  
          previousLine = cleanString(tempLine);
        }
      }
      catch (IOException e)
      {
      }      
  
      strBuf.append("\"" + (previousLine != null ? previousLine : "") + "\"" +
                    lineSeparator);
  
      return strBuf.toString();
    }
  
    // Ensure that escape sequences are passed through properly.
    public static String cleanString(String str)
    {
      if (str == null)
        return null;
      else
      {
        char[]       charArray = str.toCharArray();
        StringBuffer sBuf      = new StringBuffer();
        
        for (int i = 0; i < charArray.length; i++)
          switch (charArray[i])
          {
            case '\"' : sBuf.append("\\\"");
                        break;
            case '\\' : sBuf.append("\\\\");
                        break;
            case '\n' : sBuf.append("\\n");
                        break;
            case '\r' : sBuf.append("\\r");
                        break;
            default   : sBuf.append(charArray[i]);
                        break;
          }
        
        return sBuf.toString();
      }
    }
  
    /*
      This method will return the correct name for a class object representing
      a primitive, a single instance of a class, as well as n-dimensional arrays
      of primitives or instances. This logic is needed to handle the string returned
      from Class.getName(). If the class object represents a single instance (or
      a primitive), Class.getName() returns the fully-qualified name of the class
      and no further work is needed. However, if the class object represents an
      array (of n dimensions), Class.getName() returns a Descriptor (the Descriptor
      grammar is defined in section 4.3 of the Java VM Spec). This method will
      parse the Descriptor if necessary.
    */
    public static String getClassName(Class targetClass)
    {
      String className = targetClass.getName();
  
      return targetClass.isArray() ? parseDescriptor(className) : className;
    }
  
    /*
      See the comment above for getClassName(targetClass)...
    */
    private static String parseDescriptor(String className)
    {
      char[] classNameChars = className.toCharArray();
      int    arrayDim       = 0;
      int    i              = 0;
  
      while (classNameChars[i] == '[')
      {
        arrayDim++;
        i++;
      }
  
      StringBuffer classNameBuf = new StringBuffer();
  
      switch (classNameChars[i++])
      {
        case 'B' : classNameBuf.append("byte");
                   break;
        case 'C' : classNameBuf.append("char");
                   break;
        case 'D' : classNameBuf.append("double");
                   break;
        case 'F' : classNameBuf.append("float");
                   break;
        case 'I' : classNameBuf.append("int");
                   break;
        case 'J' : classNameBuf.append("long");
                   break;
        case 'S' : classNameBuf.append("short");
                   break;
        case 'Z' : classNameBuf.append("boolean");
                   break;
        case 'L' : classNameBuf.append(classNameChars,
                                       i, classNameChars.length - i - 1);
                   break;
      }
  
      for (i = 0; i < arrayDim; i++)
        classNameBuf.append("[]");
  
      return classNameBuf.toString();
    }
  
    public static String getCommaListFromVector(Vector sourceVector)
    {
      StringBuffer strBuf = new StringBuffer();
  
      for (int i = 0; i < sourceVector.size(); i++)
      {
        strBuf.append((i > 0 ? ", " : "") +
                      sourceVector.elementAt(i));
      }
  
      return strBuf.toString();
    }
  
    /**
     * Get a string consisting of <code>numberOfChars</code> theChars.
     *
     * @return a string consisting of <code>numberOfChars</code> theChars.
     */
    public static String getChars(int numberOfChars, char theChar)
    {
      if (numberOfChars <= 0)
        return "";
  
      StringBuffer sRet = new StringBuffer(numberOfChars);
  
      for (int i = 0; i < numberOfChars; i++)
        sRet.append(theChar);     
  
      return sRet.toString();
    }
  
    public static boolean isValidIdentifierName(String identifierName)
    {
      if (identifierName == null || identifierName.length() == 0)
        return false;
  
      char[] chars = identifierName.toCharArray();
  
      if (!Character.isJavaIdentifierStart(chars[0]))
        return false;
  
      for (int i = 1; i < chars.length; i++)
        if (!Character.isJavaIdentifierPart(chars[i]))
          return false;
  
      return true;
    }
  
    public static boolean isValidPackageName(String packageName)
    {
      if (packageName == null)
        return false;
      else if (packageName.length() == 0)
        // Empty is ok.
        return true;
  
      StringTokenizer strTok = new StringTokenizer(packageName, ".", true);
  
      // Should have an odd number of tokens (including '.' delimiters).
      if (strTok.countTokens() % 2 != 1)
        return false;
  
      // Must start with a valid identifier name.
      if (!isValidIdentifierName(strTok.nextToken()))
        return false;
  
      // ... followed by 0 or more of ".ValidIdentifier".
      while (strTok.hasMoreTokens())
      {
        // Must be a '.'.
        if (!strTok.nextToken().equals("."))
          return false;
  
        // Must be a valid identifier name.
        if (strTok.hasMoreTokens())
        {
          if (!isValidIdentifierName(strTok.nextToken()))
            return false;
        }
        else
          return false;
      }
  
      return true;
    }
  
    public static String classNameToVarName(String className)
    {
      // Might represent an array.
      int arrayDim = 0;
  
      while (className.endsWith("[]"))
      {
        className = className.substring(0, className.length() - 2);
        arrayDim++;
      }
  
      int    iLastPeriod = className.lastIndexOf('.');
      String varName     = Introspector.decapitalize(
                                           iLastPeriod != -1
                                           ? className.substring(iLastPeriod + 1)
                                           : className);
  
      if (arrayDim > 0)
      {
        varName += "_" + arrayDim + "D";
      }
  
      return getValidIdentifierName(varName);
    }
  
    public static String getValidIdentifierName(String identifierName)
    {
      if (identifierName == null || identifierName.length() == 0)
        return null;
  
      StringBuffer strBuf = new StringBuffer();
  
      char[] chars = identifierName.toCharArray();
  
      strBuf.append(Character.isJavaIdentifierStart(chars[0])
                    ? chars[0]
                    : '_'
                   );
  
      for (int i = 1; i < chars.length; i++)
      {
        strBuf.append(Character.isJavaIdentifierPart(chars[i])
                      ? chars[i]
                      : '_'
                     );
      }
  
      return strBuf.toString();
    }
  
    /*
      The recursiveDepth argument is used to insure that the algorithm gives up
      after hunting 2 levels up in the contextURL's path.
    */
    private static URL getURL(URL contextURL, String spec, int recursiveDepth)
                                                    throws MalformedURLException
    {
      URL url = null;
  
      try
      {
        url = new URL(contextURL, spec);
  
        try
        {
          url.openStream();
        }
        catch (IOException ioe1)
        {
          throw new MalformedURLException("This file was not found: " + url);
        }
      }
      catch (MalformedURLException e1)
      {
        url = new URL("file", "", spec);
  
        try
        {
          url.openStream();
        }
        catch (IOException ioe2)
        {
          if (contextURL != null)
          {
            String contextFileName = contextURL.getFile();
            String parentName      = new File(contextFileName).getParent();
  
            if (parentName != null && recursiveDepth < 3)
            {
              return getURL(new URL("file", "", parentName + '/'),
                            spec,
                            recursiveDepth + 1);
            }
          }
  
          throw new MalformedURLException("This file was not found: " + url);
        }
      }
  
      return url;
    }
  
    /*
    */
    public static URL getURL(URL contextURL, String spec) throws MalformedURLException
    {
      return getURL(contextURL, spec, 1);
    }
  
    /*
      Returns a Reader for reading from the specified resource, if the resource
      points to a stream.
    */
    public static Reader getContentAsReader(URL url) throws SecurityException,
                                                            IllegalArgumentException,
                                                            IOException
    {
      if (url == null)
      {
        throw new IllegalArgumentException("URL cannot be null.");
      }
  
      try
      {
        Object content = url.getContent();
  
        if (content == null)
        {
          throw new IllegalArgumentException("No content.");
        }
  
        if (content instanceof InputStream)
        {
          Reader in = new InputStreamReader((InputStream)content);
  
          if (in.ready())
          {
            return in;
          }
          else
          {
            throw new FileNotFoundException();
          }
        }
        else
        {
          throw new IllegalArgumentException((content instanceof String)
                                             ? (String)content
                                             : "This URL points to a: " +
                                               StringUtils.getClassName(content.getClass()));
        }
      }
      catch (SecurityException e)
      {
        throw new SecurityException("Your JVM's SecurityManager has disallowed this.");
      }
      catch (FileNotFoundException e)
      {
        throw new FileNotFoundException("This file was not found: " + url);
      }
    }
  
    /*
      Shorthand for: IOUtils.getStringFromReader(getContentAsReader(url)).
    */
    public static String getContentAsString(URL url) throws SecurityException,
                                                            IllegalArgumentException,
                                                            IOException
    {
      return IOUtils.getStringFromReader(getContentAsReader(url));
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/net/HTTPUtils.java
  
  Index: HTTPUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.net;
  
  import java.net.*;
  import java.io.*;
  import java.util.*;
  
  /**
   * A bunch of utility stuff for doing HTTP things.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class HTTPUtils {
    private static final String HTTP_VERSION = "1.0";
    private static final String HTTP_POST = "POST";
    private static final String HEADER_HOST = "Host";
    private static final String HEADER_CONTENT_TYPE = "Content-Type";
    private static final String HEADER_CONTENT_LENGTH = "Content-Length";
  
    /**
     * An instance of this class is returned by post.
     */
    static public class Response {
      int statusCode;
      String statusString;
      public Hashtable headers;
      public int contentLength;
      public String contentType;
      public BufferedReader content;
  
      Response (int statusCode, String statusString, Hashtable headers,
  	      int contentLength, String contentType, BufferedReader content) {
        this.statusCode = statusCode;
        this.statusString = statusString;
        this.headers = headers;
        this.contentLength = contentLength;
        this.contentType = contentType;
        this.content = content;
      }
    }
  
    /** 
     * POST something to the given URL. The headers are put in as 
     * HTTP headers, the content length is calculated and the content
     * is sent as content. Duh.
     *
     * @param url the url to post to
     * @param headers additional headers to send as HTTP headers
     * @param contentType type of the content
     * @param content the body of the post
     */
    public static Response post (URL url, Hashtable headers,
  			       String contentType, String content)
                 throws IllegalArgumentException {
      PrintWriter out = null;
      BufferedReader in = null;
      try {
        Socket s = new Socket (url.getHost (), url.getPort ());
        out = new PrintWriter (s.getOutputStream ());
        in = new BufferedReader (new InputStreamReader (s.getInputStream ()));
      } catch (Exception e) {
        throw new IllegalArgumentException ("error opening socket: " +
  					  e.getMessage ());
      }
  
      /* send it out */
      out.println (HTTP_POST + " " + url.getFile() + " HTTP/" + HTTP_VERSION);
      out.println (HEADER_HOST + ": " + url.getHost () + ':' + url.getPort ());
      out.println (HEADER_CONTENT_TYPE + ": " + contentType);
      out.println (HEADER_CONTENT_LENGTH + ": " + content.length ());
      for (Enumeration e = headers.keys (); e.hasMoreElements (); ) {
        Object key = e.nextElement ();
        out.println (key + ": " + headers.get (key));
      }
      out.println ();
      out.println (content);
      out.flush ();
      //    out.close ();
  
      /* read the status line */
      int statusCode = 0;
      String statusString = null;
      try {
        StringTokenizer st = new StringTokenizer (in.readLine ());
        st.nextToken (); // ignore version part
        statusCode = Integer.parseInt (st.nextToken ());
        StringBuffer sb = new StringBuffer ();
        while (st.hasMoreTokens ()) {
  	sb.append (st.nextToken ());
  	if (st.hasMoreTokens ()) {
  	  sb.append (" ");
  	}
        }
        statusString = sb.toString ();
      } catch (Exception e) {
        throw new IllegalArgumentException ("error parsing HTTP status line: " +
  					  e.getMessage ());
      }
  
      /* get the headers */
      Hashtable respHeaders = new Hashtable ();
      int respContentLength = -1;
      String respContentType = null;
      try {
        String line = null;
        while ((line = in.readLine ()) != null) {
  	if (line.length () == 0) {
  	  break;
  	}
  	int colonIndex = line.indexOf (':');
  	String fieldName = line.substring (0, colonIndex);
  	String fieldValue = line.substring (colonIndex + 1).trim ();
  	if (fieldName.equals (HEADER_CONTENT_LENGTH)) {
  	  respContentLength = Integer.parseInt (fieldValue);
  	} else if (fieldName.equals (HEADER_CONTENT_TYPE)) {
  	  respContentType = fieldValue;
  	} else {
  	  respHeaders.put (fieldName, fieldValue);
  	}
        }
      } catch (Exception e) {
        throw new IllegalArgumentException ("error reading HTTP headers: " +
  					  e.getMessage ());
      }
  
        
      /* all done */
      return new Response (statusCode, statusString, respHeaders, 
  			 respContentLength, respContentType, in);
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/net/Relay.java
  
  Index: Relay.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.net;
  
  import java.io.*;
  import java.net.*;
  import java.awt.TextArea;
  
  /**
   * A <code>Relay</code> object is used by <code>TcpTunnel</code>
   * and <code>TcpTunnelGui</code> to relay bytes from an
   * <code>InputStream</code> to a <code>OutputStream</code>.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class Relay extends Thread {
    final static int BUFSIZ = 1000;
    InputStream in;
    OutputStream out;
    byte buf[] = new byte[BUFSIZ];
    TextArea ta;
  
    Relay (InputStream in, OutputStream out, TextArea ta) {
      this.in = in;
      this.out = out;
      this.ta = ta;
    }
  
    public void run () {
      int n;
  
      try {
        while ((n = in.read (buf)) > 0) {
  	out.write (buf, 0, n);
  	out.flush ();
  	if (ta != null) {
  	  ta.append (new String (buf, 0, n));
  	}
        }
      } catch (IOException e) {
      } finally {
        try {
  	in.close ();
  	out.close ();
        } catch (IOException e) {
        }
      }
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/net/TcpTunnel.java
  
  Index: TcpTunnel.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.net;
  
  import java.net.*;
  import java.io.*;
  
  /**
   * A <code>TcpTunnel</code> object listens on the given port,
   * and once <code>Start</code> is pressed, will forward all bytes
   * to the given host and port.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class TcpTunnel {
    public static void main (String args[]) throws IOException {
      if (args.length != 3) {
        System.err.println ("Usage: java TcpTunnel listenport tunnelhost tunnelport");
        System.exit (1);
      }
  
      int listenport = Integer.parseInt (args[0]);
      String tunnelhost = args[1];
      int tunnelport = Integer.parseInt (args[2]);
  
      System.out.println ("TcpTunnel: ready to rock and roll on port " + 
  			listenport);
  
      ServerSocket ss = new ServerSocket (listenport);
      while (true) {
        // accept the connection from my client
        Socket sc = ss.accept ();
        
        // connect to the thing I'm tunnelling for
        Socket st = new Socket (tunnelhost, tunnelport);
        
        System.out.println ("TcpTunnel: tunnelling port " + listenport +
  			  " to port " + tunnelport + " on host " + 
  			  tunnelhost);
  
        // relay the stuff thru
        new Relay (sc.getInputStream(), st.getOutputStream(), null).start ();
        new Relay (st.getInputStream(), sc.getOutputStream(), null).start ();
        
        // that's it .. they're off; now I go back to my stuff.
      }
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/net/TcpTunnelGui.java
  
  Index: TcpTunnelGui.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.net;
  
  import java.net.*;
  import java.io.*;
  import java.awt.*;
  import java.awt.event.*;
  
  /**
   * A <code>TcpTunnelGui</code> object listens on the given port,
   * and once <code>Start</code> is pressed, will forward all bytes
   * to the given host and port. All traffic is displayed in a
   * UI.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class TcpTunnelGui extends Frame {
    int listenPort;
    String tunnelHost;
    int tunnelPort;
    TextArea listenText, tunnelText;
    Label status;
    Relay inRelay, outRelay;
  
    public TcpTunnelGui (int listenPort, String tunnelHost, int tunnelPort) {
      Panel p;
      
      this.listenPort = listenPort;
      this.tunnelHost = tunnelHost;
      this.tunnelPort = tunnelPort;
  
      addWindowListener (new WindowAdapter () {
        public void windowClosing (WindowEvent e) {
  	System.exit (0);
        }
      });
  
      // show info
      setTitle ("TCP Tunnel/Monitor: Tunneling localhost:" + listenPort +
  	      " to " + tunnelHost + ":" + tunnelPort);
  
      // labels
      p = new Panel ();
      p.setLayout (new BorderLayout ());
      Label l1, l2;
      p.add ("West",
  	   l1 = new Label ("From localhost:" + listenPort, Label.CENTER));
      p.add ("East",
  	   l2 = new Label ("From " + tunnelHost + ":" + tunnelPort,
  			   Label.CENTER));
      add ("North", p);
  
      // the monitor part
      p = new Panel ();
      p.setLayout (new GridLayout (-1,2));
      p.add (listenText = new TextArea ());
      p.add (tunnelText = new TextArea ());
      add ("Center", p);
  
      // clear and status
      Panel p2 = new Panel ();
      p2.setLayout (new BorderLayout ());
  
      p = new Panel ();
      Button b = new Button ("Clear");
      b.addActionListener (new ActionListener () {
        public void actionPerformed (ActionEvent e) {
  	listenText.setText ("");
  	tunnelText.setText ("");
        }
      });
      p.add (b);
      p2.add ("Center", p);
  
      p2.add ("South", status = new Label ());
      add ("South", p2);
  
      pack ();
      show ();
  
      Font f = l1.getFont ();
      l1.setFont (new Font (f.getName (), Font.BOLD, f.getSize ()));
      l2.setFont (new Font (f.getName (), Font.BOLD, f.getSize ()));
    }
  
    public int getListenPort () {
      return listenPort;
    }
  
    public String getTunnelHost () {
      return tunnelHost;
    }
  
    public int getTunnelPort () {
      return tunnelPort;
    }
    
    public TextArea getListenText () {
      return listenText;
    }
  
    public TextArea getTunnelText () {
      return tunnelText;
    }
  
    public Label getStatus () {
      return status;
    }
  
    public static void main (String args[]) throws IOException {
      if (args.length != 3) {
        System.err.println ("Usage: java TcpTunnelGui listenport tunnelhost " +
  			  "tunnelport");
        System.exit (1);
      }
      
      int listenPort = Integer.parseInt (args[0]);
      String tunnelHost = args[1];
      int tunnelPort = Integer.parseInt (args[2]);
      final TcpTunnelGui ttg = 
        new TcpTunnelGui (listenPort, tunnelHost, tunnelPort);
  
      // create the server thread
      Thread server = new Thread () {
        public void run () {
  	ServerSocket ss = null;
  	Label status = ttg.getStatus ();
  	try {
  	  ss = new ServerSocket (ttg.getListenPort ());
  	} catch (Exception e) {
  	  e.printStackTrace ();
  	  System.exit (1);
  	}
  	while (true) {
  	  try {
  	    status.setText ("Listening for connections on port " + 
  			    ttg.getListenPort () + " ...");
  	    // accept the connection from my client
  	    Socket sc = ss.accept ();
  	    
  	    // connect to the thing I'm tunnelling for
  	    Socket st = new Socket (ttg.getTunnelHost (),
  				    ttg.getTunnelPort ());
  	    
  	    status.setText ("Tunnelling port " + ttg.getListenPort () +
  			    " to port " + ttg.getTunnelPort () + 
  			    " on host " + ttg.getTunnelHost () + " ...");
  	    
  	    // relay the stuff thru
  	    new Relay (sc.getInputStream (), st.getOutputStream (),
  		       ttg.getListenText ()).start ();
  	    new Relay (st.getInputStream (), sc.getOutputStream (),
  		       ttg.getTunnelText ()).start ();
  	    
  	    // that's it .. they're off; now I go back to my stuff.
  	  } catch (Exception ee) {
  	    status.setText ("Ouch! [See console for details]: " + 
  			    ee.getMessage ());
  	    ee.printStackTrace ();
  	  }
  	}
        }
      };
      server.start ();
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/type/TypeConvertor.java
  
  Index: TypeConvertor.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: TypeConvertor.java,v 1.1 2000/05/22 00:04:22 rubys Exp $ */
  
  package org.apache.soap.util.type;
  
  /**
   * A <em>TypeConvertor</em> is used to convert an object of one type to
   * one of another type. The convertor is invoked with the class of the
   * from object, the desired class, and the from object itself. The
   * convertor must return a new object of the desired class.
   * 
   * @version  $Revision: 1.1 $
   * @author   Sanjiva Weerawarana
   * @see      TypeConvertorRegistry
   */
  public interface TypeConvertor {
    public Object convert (Class from, Class to, Object obj);
    public String getCodeGenString ();
  }
  
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/type/TypeConvertorRegistry.java
  
  Index: TypeConvertorRegistry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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/>.
   */
  
  /* $Id: TypeConvertorRegistry.java,v 1.1 2000/05/22 00:04:22 rubys Exp $ */
  
  package org.apache.soap.util.type;
  
  import java.awt.Color;
  import java.awt.Font;
  import java.util.*;
  
  /**
   * The <em>TypeConvertorRegistry</em> is the registry of type convertors.
   * It has lookup and register capabilities based on the types to be
   * converted as well as by some object key.
   * 
   * @version  $Revision: 1.1 $
   * @author   Sanjiva Weerawarana
   * @author   Matthew J. Duftler
   * @see      TypeConvertorRegistry
   */
  public class TypeConvertorRegistry {
    Hashtable reg = new Hashtable ();
    Hashtable keyedReg = new Hashtable ();
  
    // register a convertor
    public void register (Class from, Class to, TypeConvertor convertor) {
      String key = from.getName () + " -> " + to.getName ();
      reg.put (key, convertor);
    }
  
    // register a convertor by key
    public void registerByKey (Object key, TypeConvertor convertor) {
      keyedReg.put (key, convertor);
    }
  
    // lookup a convertor
    public TypeConvertor lookup (Class from, Class to) {
      String key = from.getName () + " -> " + to.getName ();
      TypeConvertor tc = (TypeConvertor) reg.get (key);
      if (tc == null) {
        Class objectClass = Object.class;
        if (from != void.class
            && from != Void.class
            && to == String.class) {
          // find the object -> string convertor
          return lookup (Object.class, String.class);
        }
      }
      return tc;
    }
  
    // lookup a convertor by key
    public TypeConvertor lookupByKey (Object key) {
      return (TypeConvertor) keyedReg.get (key);
    }
  
    // register some standard convertors at construction time
    public TypeConvertorRegistry () {
      // no-op convertors: cvt from primitive wrappers to the object wrapper
      TypeConvertor tc = new TypeConvertor () {
        public Object convert (Class from, Class to, Object obj) {
  	      return obj;
        }
      	
        public String getCodeGenString() {
          return "(Class from, Class to, Object obj) {\n" +
                 "return obj;\n" +
                 "}";
        }
      };
      register (Boolean.class, boolean.class, tc);
      register (boolean.class, Boolean.class, tc);
      register (Byte.class, byte.class, tc);
      register (byte.class, Byte.class, tc);
      register (Character.class, char.class, tc);
      register (char.class, Character.class, tc);
      register (Short.class, short.class, tc);
      register (short.class, Short.class, tc);
      register (Integer.class, int.class, tc);
      register (int.class, Integer.class, tc);
      register (Long.class, long.class, tc);
      register (long.class, Long.class, tc);
      register (Float.class, float.class, tc);
      register (float.class, Float.class, tc);
      register (Double.class, double.class, tc);
      register (double.class, Double.class, tc);
  
      // object to string: the registry special cases this one as the backup
      // if the target is string and there is no special convertor available
      // otherwise
      tc = new TypeConvertor () {
        public Object convert (Class from, Class to, Object obj) {
  	      return (obj == null) ? "(null)" : obj.toString ();
        }
      	
      	public String getCodeGenString() {
          return "(Class from, Class to, Object obj) {\n" +
                 "return (obj == null) ? \"(null)\" : obj.toString ();\n" +
                 "}";
      	}
      };
      register (Object.class, String.class, tc);
      
      // convert strings to various primitives (both their object versions
      // and wrappers for primitive versions)
      tc = new TypeConvertor () {
        public Object convert (Class from, Class to, Object obj) {
          String str = (String) obj;
          if (to == Boolean.class || to == boolean.class) {
            return Boolean.valueOf (str);
          } else if (to == Byte.class || to == byte.class) {
            return Byte.valueOf (str);
          } else if (to == Character.class || to == char.class) {
            return new Character (str.charAt (0));
          } else if (to == Short.class || to == short.class) {
            return Short.valueOf (str);
          } else if (to == Integer.class || to == int.class) {
            return Integer.valueOf (str);
          } else if (to == Long.class || to == long.class) {
            return Long.valueOf (str);
          } else if (to == Float.class || to == float.class) {
            return Float.valueOf (str);
          } else if (to == Double.class || to == double.class) {
            return Double.valueOf (str);
          } else {
            return null;
          }
        }
      	
      	public String getCodeGenString() {
          return "(Class from, Class to, Object obj) {\n" +
                 "String str = (String) obj;\n" +
                 "if (to == Boolean.class || to == boolean.class) {\n" +
                 "return Boolean.valueOf (str);\n" +
                 "} else if (to == Byte.class || to == byte.class) {\n" +
                 "return Byte.valueOf (str);\n" +
                 "} else if (to == Character.class || to == char.class) {\n" +
                 "return new Character (str.charAt (0));\n" +
                 "} else if (to == Short.class || to == short.class) {\n" +
                 "return Short.valueOf (str);\n" +
                 "} else if (to == Integer.class || to == int.class) {\n" +
                 "return Integer.valueOf (str);\n" +
                 "} else if (to == Long.class || to == long.class) {\n" +
                 "return Long.valueOf (str);\n" +
                 "} else if (to == Float.class || to == float.class) {\n" +
                 "return Float.valueOf (str);\n" +
                 "} else if (to == Double.class || to == double.class) {\n" +
                 "return Double.valueOf (str);\n" +
                 "} else {\n" +
                 "return null;\n" +
                 "}\n" +
                 "}";
        }
      };
      register (String.class, boolean.class, tc);
      register (String.class, Boolean.class, tc);
      register (String.class, byte.class, tc);
      register (String.class, Byte.class, tc);
      register (String.class, char.class, tc);
      register (String.class, Character.class, tc);
      register (String.class, short.class, tc);
      register (String.class, Short.class, tc);
      register (String.class, int.class, tc);
      register (String.class, Integer.class, tc);
      register (String.class, long.class, tc);
      register (String.class, Long.class, tc);
      register (String.class, float.class, tc);
      register (String.class, Float.class, tc);
      register (String.class, double.class, tc);
      register (String.class, Double.class, tc);
  
      // strings to fonts
      tc = new TypeConvertor () {
        public Object convert (Class from, Class to, Object obj) {
  	      return Font.decode ((String) obj);
        }
      	
        public String getCodeGenString() {
          return "(Class from, Class to, Object obj) {\n" +
                 "return Font.decode ((String) obj);\n" +
                 "}";
        }
      };
      register (String.class, Font.class, tc);
  
      // strings to colors
      tc = new TypeConvertor () {
        public Object convert (Class from, Class to, Object obj) {
  	      return Color.decode ((String) obj);
        }
      	
      	public String getCodeGenString() {
          return "(Class from, Class to, Object obj) {\n" +
                 "return Color.decode ((String) obj);\n" +
                 "}";
      	}
      };
      register (String.class, Color.class, tc);
    }
  }
  
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/DOM2Writer.java
  
  Index: DOM2Writer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  
  /**
   * This class is a utility to serialize a DOM node as XML. This class
   * uses the <code>DOM Level 2</code> APIs.
   * The main difference between this class and DOMWriter is that this class
   * generates and prints out namespace declarations.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Joseph Kesselman
   */
  public class DOM2Writer
  {
    /**
     * The namespaceURI represented by the prefix <code>xmlns</code>.
     */
    private static String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/";
  
    /**
     * Return a string containing this node serialized as XML.
     */
    public static String nodeToString(Node node)
    {
      StringWriter sw = new StringWriter();
  
      serializeAsXML(node, sw);
  
      return sw.toString();
    }
  
    /**
    * Serialize this node into the writer as XML.
    */
    public static void serializeAsXML(Node node, Writer writer)
    {
      print(node, null, new PrintWriter(writer));
    }
  
    private static void print(Node node, ObjectRegistry namespaceStack,
                              PrintWriter out)
    {
      if (node == null)
      {
        return;
      }
  
      boolean hasChildren = false;
      int type = node.getNodeType();
  
      switch (type)
      {
        case Node.DOCUMENT_NODE :
        {
          out.println("<?xml version=\"1.0\"?>");
  
          NodeList children = node.getChildNodes();
  
          if (children != null)
          {
            int numChildren = children.getLength();
  
            for (int i = 0; i < numChildren; i++)
            {
              print(children.item(i), namespaceStack, out);
            }
          }
          break;
        }
  
        case Node.ELEMENT_NODE :
        {
          namespaceStack = new ObjectRegistry(namespaceStack);
  
          out.print('<' + node.getNodeName());
  
          String elPrefix = node.getPrefix();
          String elNamespaceURI = node.getNamespaceURI();
  
          if (elPrefix != null && elNamespaceURI != null)
          {
            boolean prefixIsDeclared = false;
  
            try
            {
              String namespaceURI = (String)namespaceStack.lookup(elPrefix);
  
              if (elNamespaceURI.equals(namespaceURI))
              {
                prefixIsDeclared = true;
              }
            }
            catch (IllegalArgumentException e)
            {
            }
  
            if (!prefixIsDeclared)
            {
              printNamespaceDecl(node, namespaceStack, out);
            }
          }
  
          NamedNodeMap attrs = node.getAttributes();
          int len = (attrs != null) ? attrs.getLength() : 0;
  
          for (int i = 0; i < len; i++)
          {
            Attr attr = (Attr)attrs.item(i);
  
            out.print(' ' + attr.getNodeName() +"=\"" +
                      normalize(attr.getValue()) + '\"');
  
            String attrPrefix = attr.getPrefix();
            String attrNamespaceURI = attr.getNamespaceURI();
  
            if (attrPrefix != null && attrNamespaceURI != null)
            {
              boolean prefixIsDeclared = false;
  
              try
              {
                String namespaceURI = (String)namespaceStack.lookup(attrPrefix);
  
                if (attrNamespaceURI.equals(namespaceURI))
                {
                  prefixIsDeclared = true;
                }
              }
              catch (IllegalArgumentException e)
              {
              }
  
              if (!prefixIsDeclared)
              {
                printNamespaceDecl(attr, namespaceStack, out);
              }
            }
          }
  
          NodeList children = node.getChildNodes();
  
          if (children != null)
          {
            int numChildren = children.getLength();
  
            hasChildren = (numChildren > 0);
  
            if (hasChildren)
            {
              out.print('>');
            }
  
            for (int i = 0; i < numChildren; i++)
            {
              print(children.item(i), namespaceStack, out);
            }
          }
          else
          {
            hasChildren = false;
          }
  
          if (!hasChildren)
          {
            out.print("/>");
          }
          break;
        }
  
        case Node.ENTITY_REFERENCE_NODE :
        {
          out.print('&');
          out.print(node.getNodeName());
          out.print(';');
          break;
        }
  
        case Node.CDATA_SECTION_NODE :
        {
          out.print("<![CDATA[");
          out.print(node.getNodeValue());
          out.print("]]>");
          break;
        }
  
        case Node.TEXT_NODE :
        {
          out.print(normalize(node.getNodeValue()));
          break;
        }
  
        case Node.COMMENT_NODE :
        {
          out.print("<!--");
          out.print(node.getNodeValue());
          out.print("-->");
          break;
        }
  
        case Node.PROCESSING_INSTRUCTION_NODE :
        {
          out.print("<?");
          out.print(node.getNodeName());
  
          String data = node.getNodeValue();
  
          if (data != null && data.length() > 0)
          {
            out.print(' ');
            out.print(data);
          }
  
          out.println("?>");
          break;
        }
      }
  
      if (type == Node.ELEMENT_NODE && hasChildren == true)
      {
        out.print("</");
        out.print(node.getNodeName());
        out.print('>');
        hasChildren = false;
      }
    }
  
    private static void printNamespaceDecl(Node node,
                                           ObjectRegistry namespaceStack,
                                           PrintWriter out)
    {
      switch (node.getNodeType())
      {
        case Node.ATTRIBUTE_NODE :
        {
          printNamespaceDecl(((Attr)node).getOwnerElement(), node,
                             namespaceStack, out);
          break;
        }
  
        case Node.ELEMENT_NODE :
        {
          printNamespaceDecl((Element)node, node, namespaceStack, out);
          break;
        }
      }
    }
  
    private static void printNamespaceDecl(Element owner, Node node,
                                           ObjectRegistry namespaceStack,
                                           PrintWriter out)
    {
      String namespaceURI = node.getNamespaceURI();
      String prefix = node.getPrefix();
  
      if (!(namespaceURI.equals(NS_URI_XMLNS) && prefix.equals("xmlns")))
      {
        if (owner.getAttributeNS(NS_URI_XMLNS, prefix) == null)
        {
          out.print(" xmlns:" + prefix + "=\"" + namespaceURI + '\"');
        }
      }
      else
      {
        prefix = node.getLocalName();
        namespaceURI = node.getNodeValue();
      }
  
      namespaceStack.register(prefix, namespaceURI);
    }
  
    private static String normalize(String s)
    {
      StringBuffer str = new StringBuffer();
      int len = (s != null) ? s.length() : 0;
  
      for (int i = 0; i < len; i++)
      {
        char ch = s.charAt(i);
  
        switch (ch)
        {
          case '<' :
          {
            str.append("&lt;");
            break;
          }
          case '>' :
          {
            str.append("&gt;");
            break;
          }
          case '&' :
          {
            str.append("&amp;");
            break;
          }
          case '"' :
          {
            str.append("&quot;");
            break;
          }
          case '\n' :
          {
            if (i > 0)
            {
              char lastChar = str.charAt(str.length() - 1);
  
              if (lastChar != '\r')
              {
                str.append(StringUtils.lineSeparator);
              }
              else
              {
                str.append('\n');
              }
            }
            else
            {
              str.append(StringUtils.lineSeparator);
            }
            break;
          }
          default :
          {
            str.append(ch);
          }
        }
      }
  
      return (str.toString());
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/DOMWriter.java
  
  Index: DOMWriter.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.StringUtils;
  
  /**
   * This class is a utility to serialize a DOM node as XML. This code is
   * derived from the sample of the same name distributed with XML4J_2_0_15.
   * The following significant changes were made:
   * comments and top-level PIs, now uses short-hand element syntax when an
   * element is childless, now attempts to use the correct line-termination
   * sequence. Also: removed the code related to canonical ordering, alternate
   * encodings, and use as a stand-alone utility.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   */
  public class DOMWriter
  {
    /**
     * Return a string containing this node serialized as XML.
     */
    public static String nodeToString(Node node)
    {
      StringWriter sw = new StringWriter();
  
      serializeAsXML(node, sw);
  
      return sw.toString();
    }
  
    /**
    * Serialize this node into the writer as XML.
    */
    public static void serializeAsXML(Node node, Writer writer)
    {
      print(node, new PrintWriter(writer));
    }
  
    private static void print(Node node, PrintWriter out)
    {
      if (node == null)
      {
        return;
      }
  
      boolean hasChildren = false;
      int type = node.getNodeType();
  
      switch (type)
      {
        case Node.DOCUMENT_NODE :
        {
          out.println("<?xml version=\"1.0\"?>");
  
          NodeList children = node.getChildNodes();
  
          if (children != null)
          {
            int numChildren = children.getLength();
  
            for (int i = 0; i < numChildren; i++)
            {
              print(children.item(i), out);
            }
          }
          break;
        }
  
        case Node.ELEMENT_NODE :
        {
          out.print('<' + node.getNodeName());
  
          NamedNodeMap attrs = node.getAttributes();
          int len = (attrs != null) ? attrs.getLength() : 0;
  
          for (int i = 0; i < len; i++)
          {
            Attr attr = (Attr)attrs.item(i);
  
            out.print(' ' + attr.getNodeName() +"=\"" +
                      normalize(attr.getValue()) + '\"');
          }
  
          NodeList children = node.getChildNodes();
  
          if (children != null)
          {
            int numChildren = children.getLength();
  
            hasChildren = (numChildren > 0);
  
            if (hasChildren)
            {
              out.print('>');
            }
  
            for (int i = 0; i < numChildren; i++)
            {
              print(children.item(i), out);
            }
          }
          else
          {
            hasChildren = false;
          }
  
          if (!hasChildren)
          {
            out.print("/>");
          }
          break;
        }
  
        case Node.ENTITY_REFERENCE_NODE :
        {
          out.print('&');
          out.print(node.getNodeName());
          out.print(';');
          break;
        }
  
        case Node.CDATA_SECTION_NODE :
        {
          out.print("<![CDATA[");
          out.print(node.getNodeValue());
          out.print("]]>");
          break;
        }
  
        case Node.TEXT_NODE :
        {
          out.print(normalize(node.getNodeValue()));
          break;
        }
  
        case Node.COMMENT_NODE :
        {
          out.print("<!--");
          out.print(node.getNodeValue());
          out.print("-->");
          break;
        }
  
        case Node.PROCESSING_INSTRUCTION_NODE :
        {
          out.print("<?");
          out.print(node.getNodeName());
  
          String data = node.getNodeValue();
  
          if (data != null && data.length() > 0)
          {
            out.print(' ');
            out.print(data);
          }
  
          out.println("?>");
          break;
        }
      }
  
      if (type == Node.ELEMENT_NODE && hasChildren == true)
      {
        out.print("</");
        out.print(node.getNodeName());
        out.print('>');
        hasChildren = false;
      }
    }
  
    private static String normalize(String s)
    {
      StringBuffer str = new StringBuffer();
      int len = (s != null) ? s.length() : 0;
  
      for (int i = 0; i < len; i++)
      {
        char ch = s.charAt(i);
  
        switch (ch)
        {
          case '<' :
          {
            str.append("&lt;");
            break;
          }
          case '>' :
          {
            str.append("&gt;");
            break;
          }
          case '&' :
          {
            str.append("&amp;");
            break;
          }
          case '"' :
          {
            str.append("&quot;");
            break;
          }
          case '\n' :
          {
            if (i > 0)
            {
              char lastChar = str.charAt(str.length() - 1);
  
              if (lastChar != '\r')
              {
                str.append(StringUtils.lineSeparator);
              }
              else
              {
                str.append('\n');
              }
            }
            else
            {
              str.append(StringUtils.lineSeparator);
            }
            break;
          }
          default :
          {
            str.append(ch);
          }
        }
      }
  
      return (str.toString());
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/Deserializer.java
  
  Index: Deserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  
  /**
   * A <code>Deserializer</code> ...
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Francisco Curbera (curbera@us.ibm.com)
   */
  public interface Deserializer
  {
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException;
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/DomHash.java
  
  Index: DomHash.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.util.Vector;
  import java.io.*;
  import org.w3c.dom.*;
  import java.util.zip.*;
  
  
  public class DomHash
  {
  
    public static CRC32 crc = new CRC32();
    
    //
    // Hash computation code
    //
    public static long getElementHash(Element element)
    {
      Attr atts[]=null;    
      long hash = 0;
  
      try 
        {
  	ByteArrayOutputStream baos = new ByteArrayOutputStream();
  	DataOutputStream dos = new DataOutputStream(baos);
  	dos.writeInt(Node.ELEMENT_NODE); // Node type
  	dos.write(element.getTagName().getBytes() ); 
  	
  	dos.write((byte)0);
  	dos.write((byte)0);
  	
  
  	//
  	// sort the attributes now
  	//
  	int atlen=0;
  	NamedNodeMap attributes = element.getAttributes();
  	if (null != attributes && (atlen = attributes.getLength())!=0 ) 
  	  {    
  	    Attr at;
  	    atts = new Attr[atlen];
  	    Vector as = new Vector(); 
  	    for (int i = 0;  i < atlen;  i ++)
  	      as.addElement(attributes.item(i).getNodeName());
  	    sortStringVector(as);
  	    for (int i = 0;  i < atlen;  i ++) 
  	      {
  		at = (Attr)element.getAttributeNode((String)as.elementAt(i));		 
  		atts[i] = at;		
  	      }
  	  }
  
  	if (null == atts || (atlen = atts.length)==0 ) 
  	  { // Number of attributes
  	    dos.writeInt(0);
  	  } 
  	else
  	  {	    
  	    dos.writeInt(atlen);
  	    	       
  	    Attr at;
  	    
  	    for (int i = 0;  i < atlen;  i ++) 
  	      {
  		at = atts[i];
  		dos.writeInt((int)Node.ATTRIBUTE_NODE);
  		dos.writeBytes(at.getName());
  		dos.writeBytes(at.getValue()); 		
  	      }
  	  }
  
  	//
  	// Done with attributes - may simplify this code
  	//
  
  	dos.close();	
  	crc.reset();
  	crc.update(baos.toByteArray());
  	hash = crc.getValue();
        }
      catch(Exception exception) 
        {	
        	exception.printStackTrace();
        }
  	
      return hash; 
    }
  	
    public static void updateLong(Checksum crc, long add)
    {
      crc.update((byte)((add>>56) & 0xff));
      crc.update((byte)((add>>48) & 0xff));
      crc.update((byte)((add>>40) & 0xff));
      crc.update((byte)((add>>32) & 0xff));
      crc.update((byte)((add>>24) & 0xff));
      crc.update((byte)((add>>16) & 0xff));
      crc.update((byte)((add>>8) & 0xff));	
      crc.update((byte)(add & 0xff));
    }
    private static Vector sortStringVector(Vector vector) 
    {
      String[] as = new String[vector.size()];
      vector.copyInto(as);
      heapSort(as);
      vector.removeAllElements();
      vector.ensureCapacity(as.length);
      for (int i = 0;  i < as.length;  i ++)
          vector.addElement(as[i]);
      return vector;
    }
  
    private static void heapSort(String[] pd) {
      int i;
      for (i = pd.length/2;  i >= 0;  i--) {  // Make heap
        fall(pd, pd.length, i);
      }
      for (i = pd.length-1;  i > 0;  i--) {
        String t = pd[0];
        pd[0] = pd[i];
        pd[i] = t;
        fall(pd, i, 0);
      }
    }
    
    private static void fall(String[] pd, int n, int i) {
      int j = 2*i+1;
      if (j < n) {                            // left exists
        if (j+1 < n) {                      // right exists too
  	// j: bigger
  	if (0 > pd[j].compareTo(pd[j+1]))
  	  j = 2*i+2;
        } else {                            // only left
        }
        if (0 > pd[i].compareTo(pd[j])) {
  	// the child is bigger
  	String t = pd[i];
  	pd[i] = pd[j];
  	pd[j] = t;
  	fall(pd, n, j);
        }
      }
    }
  
    public static String getXMLDisplayString(String in)
    {
      char[] work = new char[in.length()*2];
      String ltS = "&lt;";
      String gtS = "&gt;";
      boolean done = false;
      int lt = 0, gt = 0, start = 0, length = 0;
      while( !done )
        {
  	lt = in.indexOf('<', start);	
  	gt = in.indexOf('>', lt); 
  	if( lt>=start )
  	  {                    
  	    in.getChars(start, lt, work, length);
  	    length += lt-start;
  	    ltS.getChars(0, ltS.length(), work, length);	           
  	    length += ltS.length();
  	  }
  	else
  	  break;
  	if( gt>lt ) 
  	  {
  	    in.getChars(lt+1, gt, work, length);
  	    length += gt-lt-1;
  	    gtS.getChars(0, gtS.length(), work, length);
  	    length += gtS.length();
  	    start = gt+1;
  	  }
  	else
  	  break;
  	if( lt>in.length() || gt > in.length() ) done=true;       
        }
      return new String(work);
      
    }
    
  
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/NSStack.java
  
  Index: NSStack.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.io.*;
  import java.util.*;
  
  /**
   * This class implements a namespace stack for XML apps to use. If
   * you need to keep track of namespaces in scope, then this class is
   * for you.  Every time you enter a new element and wish to add some
   * namespace declarations that are to be visible within that
   * element, you should call <tt>pushScope</tt> to create a new
   * scope. Then, call <tt>addNSDeclaration</tt> any number of times to
   * add new declarations for that scope. Scopes nest inside out; that
   * is, any NS declaration added into a scope is visible from any
   * scopes that are pushed later. When you want to see whether an NS
   * declaration has already been made for a certain URI, you should
   * call <tt>getPrefixInScopeForURI</tt> to get the prefix that has
   * been bound to that URI. There is a covenience version of
   * <tt>addNSDecalration</tt> which can be used if you want me to give
   * you a not-so-random, yet unique, prefix for your namespace
   * declaration.
   *
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class NSStack {
    Vector nss = new Vector (); // vector holding vectors of ns decls (stack)
    int nssCount = 0;           // number of items on the stack
    Vector tos;                 // the vector @ the top of the stack
    private final static String nsPrefixPrefix = "ns";
    private int nsPrefixCount = 1;
  
    /**
     * Enter a new scope: after calling this I'm ready to accept new
     * declarations into that scope.
     */
    public void pushScope () {
      nss.addElement (tos = new Vector ());
      nssCount++;
    }
  
    /**
     * Leave a scope: this removes any NS declarations that were added
     * in the last scope. Note that I don't bother to validate that you
     * don't call popScope too many times; that's your problem.
     */
    public void popScope () {
      nss.removeElementAt (--nssCount);
      tos = (nssCount != 0) ? (Vector) nss.elementAt (nssCount-1) : null;
    }
  
    /**
     * Add a new declaration to the current scope. This is visible within
     * the current scope as well as from any nested scopes. 
     *
     * @param prefix the prefix to be used for this namespace
     * @param URI the namespace name of this namespace.
     */
    synchronized public void addNSDeclaration (String prefix, String URI) {
      tos.addElement (new NSDecl (prefix, URI));
    }
  
    /**
     * Add a new declaration to the current scope using a unique prefix
     * and return the prefix. This is useful when one just wants to add a
     * decl and doesn't want to have to deal with creating unique prefixes.
     * If the namespace name is already declared and in scope, then the 
     * previously declared prefix is returned.
     *
     * @param URI the namespace name of this namespace
     * @return the unique prefix created or previously declared
     *         for this namespace
     */
    synchronized public String addNSDeclaration (String URI) {
      String uniquePrefix = getPrefixFromURI (URI);
      if (uniquePrefix == null) {
        do {
  	      uniquePrefix = nsPrefixPrefix + nsPrefixCount++;
        } while (getURIFromPrefix (uniquePrefix) != null);
        addNSDeclaration (uniquePrefix, URI);
      }
      return uniquePrefix;
    }
  
    /**
     * Return the prefix associated with the given namespace name by
     * looking thru all the namespace declarations that are in scope.
     *
     * @param URI the namespace name for whom a declared prefix is desired
     * @return the prefix or null if namespace name not found
     */
    public String getPrefixFromURI (String URI) {
      for (int i = nssCount-1; i >= 0; i--) {
        Vector scope = (Vector) nss.elementAt (i);
        for (Enumeration e = scope.elements (); e.hasMoreElements (); ) {
          NSDecl nsd = (NSDecl) e.nextElement ();
          if (nsd.URI.equals (URI)) {
            return nsd.prefix;
          }
        }
      }
      return null;
    }
  
    /**
     * Return the prefix associated with the given namespace name by
     * looking thru all the namespace declarations that are in scope.
     * If the namespace declaration is not found, create one and
     * return the generated prefix.
     *
     * @param URI the namespace name for whom a declared prefix is desired
     * @return the prefix (will never return null)
     */
    synchronized public String getPrefixFromURI (String namespaceURI,
                                                 Writer sink)
      throws IOException {
      String prefix = getPrefixFromURI (namespaceURI);
  
      if (prefix == null) {
        prefix = addNSDeclaration (namespaceURI);
  
        sink.write (" xmlns:" + prefix + "=\"" + namespaceURI + '\"');
      }
  
      return prefix;
    }
  
    /**
     * Return the namespace name associated with the given prefix by
     * looking thru all the namespace declarations that are in scope.
     *
     * @param prefix the prefix for whom a declared namespace name is desired
     * @return the namespace name or null if prefix not found
     */
    public String getURIFromPrefix (String prefix) {
      for (int i = nssCount-1; i >= 0; i--) {
        Vector scope = (Vector) nss.elementAt (i);
        for (Enumeration e = scope.elements (); e.hasMoreElements (); ) {
          NSDecl nsd = (NSDecl) e.nextElement ();
          if (nsd.prefix.equals (prefix)) {
            return nsd.URI;
          }
        }
      }
      return null;
    }
  
    // MJD - debug
    public String toString()
    {
      return nss.toString();
    }
    // MJD - debug
  }
  
  /**
   * Utility class to hold a single declaration.
   */
  class NSDecl {
    String prefix;
    String URI;
  
    NSDecl (String prefix, String URI) {
      this.prefix = prefix;
      this.URI = URI;
    }
    
    // MJD - debug
    public String toString()
    {
      return prefix + "->" + URI;
    }
    // MJD - debug
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/QName.java
  
  Index: QName.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import org.w3c.dom.Node;
  
  /**
   * A <code>QName</code> represents a fully-qualified name.
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class QName implements java.io.Serializable
  {
    private String namespaceURI;
    private String localPart;
  
    public QName()
    {
      // no args constructor for use as bean
    }
  
    public QName(Node node) throws IllegalArgumentException
    {
      String namespaceURI = node.getNamespaceURI();
  
      if (namespaceURI == null)
      {
        throw new IllegalArgumentException("Can't create QName: NamespaceURI " +
                                           "must not be null.");
      }
  
      String localPart = node.getLocalName();
  
      if (localPart == null)
      {
        throw new IllegalArgumentException("Can't create QName: LocalName " +
                                           "must not be null.");
      }
  
      setNamespaceURI(namespaceURI);
      setLocalPart(localPart);
    }
  
    public QName(String namespaceURI, String localPart)
    {
      setNamespaceURI(namespaceURI);
      setLocalPart(localPart);
    }
  
    public void setNamespaceURI(String namespaceURI)
    {
      this.namespaceURI = namespaceURI.intern();
    }
  
    public String getNamespaceURI()
    {
      return namespaceURI;
    }
  
    public void setLocalPart(String localPart)
    {
      this.localPart = localPart.intern();
    }
  
    public String getLocalPart()
    {
      return localPart;
    }
  
    public int hashCode()
    {
      String hash1 = namespaceURI.hashCode() + "";
      String hash2 = localPart.hashCode() + "";
      String hash3 = hash1 + '_' + hash2;
  
      return hash3.hashCode();
    }
  
    public boolean equals(Object obj)
    {
      return (obj != null
              && namespaceURI == ((QName)obj).getNamespaceURI()
              && localPart == ((QName)obj).getLocalPart());
    }
  
    public boolean matches(Node node)
    {
      try
      {
        return (node != null && this.equals(new QName(node)));
      }
      catch (IllegalArgumentException e)
      {
        return false;
      }
    }
  
    public String toString()
    {
      return namespaceURI + ':' + localPart;
    }
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/Serializer.java
  
  Index: Serializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.io.*;
  import org.w3c.dom.*;
  
  /**
   * A <code>Serializer</code> ...
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Francisco Curbera (curbera@us.ibm.com)
   */
  public interface Serializer
  {
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
      throws IllegalArgumentException, IOException;
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/XMIDeserializer.java
  
  Index: XMIDeserializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import com.ibm.xmi.job.*;
  import java.io.*;
  import java.util.*;
  import org.apache.soap.util.Bean;
  import org.w3c.dom.*;
  
  /**
   * An <code>XMIDeserializer</code> ...
   *
   * @author Francisco Curbera (curbera@us.ibm.com)
   */
  public class XMIDeserializer implements Deserializer
  {
  
    static String XMIheader = "<?xml version='1.0' encoding='UTF-8'?><XMI xmi.version='1.1' timestamp='timestamp temporarily ommitted'><XMI.header><XMI.documentation><XMI.exporter>Java Object Bridge (JOB)</XMI.exporter><XMI.exporterVersion>0.9</XMI.exporterVersion></XMI.documentation></XMI.header><XMI.content>";
  
    static String XMIend = "</XMI.content></XMI>";
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src,
                           XMLJavaMappingRegistry xjmr)
         throws IllegalArgumentException
  
    {
      // needs no mapping registry
      // no QName
      // assumes encoding style is XMI
  
      // need to serialize the node into an output stream
            
      String xmlString = DOMWriter.nodeToString(src);
      String document = XMIheader + xmlString + XMIend;
      byte[] bytes = document.getBytes();
      ByteArrayInputStream bs = new  ByteArrayInputStream(bytes);
  
      com.ibm.xmi.framework.WriterFactory.setInline(true);
      Collection objects = Job.readObjects(bs);
  
      try{
        bs.close();
      }catch(IOException e){
        e.printStackTrace(System.err);
      }
  	
      
      Iterator it = objects.iterator();
  
      Object o;
      // assumethat there was one object encoded at most
      if( it.hasNext() )
        return new Bean((o=it.next()).getClass(), o);
      else
        throw new IllegalArgumentException("Unable to unmarshall XMI-encoded " +
                                           "object.");
       			    
    } 
    
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/XMISerializer.java
  
  Index: XMISerializer.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import com.ibm.xmi.job.*;
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  
  /**
   * An <code>XMISerializer</code> ...
   *
   * @author Francisco Curbera (curbera@us.ibm.com)
   */
  public class XMISerializer implements Serializer
  {
    public static int CONV_BSIZE=0x400;
    private static XercesParserLiaison xpl = null;
  
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack,
                         XMLJavaMappingRegistry xjmr)
         throws IllegalArgumentException, IOException
  
    {
  
      //
      // not using namespaces - this is under the Job classes control
      // may need to check that the encoding style is in fact xmi...
      // ignoring context
  
      // special case for Strings - otherwise treated as uuids by the serializer
      
      if( xpl == null )
        xpl = new  XercesParserLiaison();
      
      if (src == null)
      {
        sink.write("<null type=\"" + javaType.getName() + "\"/>");
        return;
      }
      else if( javaType ==java.lang.String.class )
      {	
        sink.write("<java.lang.String value='" + src + "' />");
        return;
      }
      
      System.err.println(src);
      Vector olist = new Vector();
      olist.addElement(src);
      
      
      PipedOutputStream tmpout = new PipedOutputStream();
      PipedInputStream tmpin  = new PipedInputStream();
      
      tmpin.connect(tmpout);
  
      com.ibm.xmi.framework.WriterFactory.setInline(true);
      Job.writeObjects((List)olist, (OutputStream)tmpout);
                 
      byte[] readinto = new byte[XMISerializer.CONV_BSIZE];
      int len, left = 0;
      
      while( (left = tmpin.available())> 0 )
        {
  	len = tmpin.read(readinto, 0, Math.min(left, XMISerializer.CONV_BSIZE));
  	String convert = new String(readinto, 0, len);
  	sink.write(convert);
        }
      
      tmpout.close();
      tmpin.close();
    }
    
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/XMLJavaMappingRegistry.java
  
  Index: XMLJavaMappingRegistry.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.io.*;
  import java.util.*;
  import org.w3c.dom.*;
  import org.apache.soap.util.*;
  
  /**
   * An <code>XMLJavaMappingRegistry</code> ...
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   * @author Francisco Curbera (curbera@us.ibm.com)
   */
  public class XMLJavaMappingRegistry
  {
    private Hashtable sReg        = new Hashtable();
    private Hashtable dsReg       = new Hashtable();
    private Hashtable xml2JavaReg = new Hashtable();
    private Hashtable java2XMLReg = new Hashtable();
  
    // To register the default, set both types to null.
    public void mapTypes(String encodingStyleURI, QName elementType,
                         Class javaType, Serializer s, Deserializer ds)
    {
      String java2XMLKey = getKey(javaType, encodingStyleURI);
      String xml2JavaKey = getKey(elementType, encodingStyleURI);
  
      if (s != null)
      {
        sReg.put(java2XMLKey, s);
      }
  
      if (ds != null)
      {
        dsReg.put(xml2JavaKey, ds);
      }
  
      // Only map types if both types are provided.
      if (elementType != null && javaType != null)
      {
        java2XMLReg.put(java2XMLKey, elementType);
        xml2JavaReg.put(xml2JavaKey, javaType);
      }
    }
  
    public Serializer querySerializer(Class javaType, String encodingStyleURI)
      throws IllegalArgumentException
    {
      String java2XMLKey = getKey(javaType, encodingStyleURI);
      Serializer s = (Serializer)sReg.get(java2XMLKey);
  
      if (s != null)
      {
        return s;
      }
      else
      {
        java2XMLKey = getKey(null, encodingStyleURI);
        s = (Serializer)sReg.get(java2XMLKey);
  
        if (s != null)
        {
          return s;
        }
        else
        {
          throw new IllegalArgumentException("No Serializer found to " +
                                             "serialize a '" +
                                             getClassName(javaType) +
                                             "' using encoding style '" +
                                             encodingStyleURI + "'.");
        }
      }
    }
  
    public Deserializer queryDeserializer(QName elementType,
                                          String encodingStyleURI)
      throws IllegalArgumentException
    {
      String xml2JavaKey = getKey(elementType, encodingStyleURI);
      Deserializer ds = (Deserializer)dsReg.get(xml2JavaKey);
  
      if (ds != null)
      {
        return ds;
      }
      else
      {
        xml2JavaKey = getKey(null, encodingStyleURI);
        ds = (Deserializer)dsReg.get(xml2JavaKey);
  
        if (ds != null)
        {
          return ds;
        }
        else
        {
          throw new IllegalArgumentException("No Deserializer found to " +
                                             "deserialize a '" + elementType +
                                             "' using encoding style '" +
                                             encodingStyleURI + "'.");
        }
      }
    }
  
    public QName queryElementType(Class javaType, String encodingStyleURI)
      throws IllegalArgumentException
    {
      String java2XMLkey = getKey(javaType, encodingStyleURI);
      QName elementType = (QName)java2XMLReg.get(java2XMLkey);
  
      if (elementType != null)
      {
        return elementType;
      }
      else
      {
        throw new IllegalArgumentException("No mapping found for '" +
                                           getClassName(javaType) +
                                           "' using encoding style '" +
                                           encodingStyleURI + "'.");
      }
    }
  
    public Class queryJavaType(QName elementType, String encodingStyleURI)
      throws IllegalArgumentException
    {
      String xml2JavaKey = getKey(elementType, encodingStyleURI);
      Class javaType = (Class)xml2JavaReg.get(xml2JavaKey);
  
      if (javaType != null)
      {
        return javaType;
      }
      else
      {
        throw new IllegalArgumentException("No mapping found for '" +
                                           elementType +
                                           "' using encoding style '" +
                                           encodingStyleURI + "'.");
      }
    }
  
    public void marshall(String inScopeEncStyle, Class javaType, Object src,
                         Object context, Writer sink, NSStack nsStack)
      throws IllegalArgumentException, IOException
    {
      Serializer s = (Serializer)querySerializer(javaType, inScopeEncStyle);
  
      s.marshall(inScopeEncStyle, javaType, src, context, sink, nsStack, this);
    }
  
    public Bean unmarshall(String inScopeEncStyle, QName elementType, Node src)
      throws IllegalArgumentException
    {
      Deserializer ds = (Deserializer)queryDeserializer(elementType,
                                                        inScopeEncStyle);
  
      return ds.unmarshall(inScopeEncStyle, elementType, src, this);
    }
  
    private static String getKey(Object type, String encodingStyleURI)
    {
      return type + " + " + encodingStyleURI;
    }
  
    private static String getClassName(Class javaType)
    {
      return javaType != null ? StringUtils.getClassName(javaType) : "null";
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/XMLParserLiaison.java
  
  Index: XMLParserLiaison.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.io.*;
  import org.w3c.dom.*;
  
  /**
   * An interface between a client and an XML-parser.
   * 
   * @author   Matthew J. Duftler
   * @author   Sanjiva Weerawarana
   * @author   Paco Curbera
   * @author   Joseph Kesselman
   */
  public interface XMLParserLiaison
  {
    public Document read (String sourceDesc, Reader reader);
  
    public Document createDocument ();
  }
  
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/XPathUtils.java
  
  Index: XPathUtils.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.util.Vector;
  import org.w3c.dom.*;
  
  /**
   * A <code>XPathUtils</code> ...
   *
   * @author Matthew J. Duftler (duftler@us.ibm.com)
   * @author Sanjiva Weerawarana (sanjiva@watson.ibm.com)
   */
  public class XPathUtils
  {
    private static Node getPreviousTypedNode(Node node, short nodeType)
    {
      node = node.getPreviousSibling();
  
      while (node != null && node.getNodeType() != nodeType)
      {
        node = node.getPreviousSibling();
      }
  
      return node;
    }
  
    private static Node getNextTypedNode(Node node, short nodeType)
    {
      node = node.getNextSibling();
  
      while (node != null && node.getNodeType() != nodeType)
      {
        node = node.getNextSibling();
      }
  
      return node;
    }
  
    private static String getValue(Node node, short nodeType)
    {
      switch (nodeType)
      {
        case Node.ELEMENT_NODE :
          return ((Element)node).getTagName();
  
        case Node.TEXT_NODE :
          return ((Text)node).getData();
  
        case Node.PROCESSING_INSTRUCTION_NODE :
          return ((ProcessingInstruction)node).getData();
  
        default :
          return "";
      }
    }
  
    private static short getNodeType(Node node)
    {
      return (node != null ? node.getNodeType() : -1);
    }
  
    private static String getXPathFromVector(Vector path)
    {
      StringBuffer strBuf = new StringBuffer();
      int          length = path.size();
  
      for (int i = 0; i < length; i++)
      {
        Node   tempNode    = (Node)path.elementAt(i);
        short  nodeType    = getNodeType(tempNode);
        String targetValue = getValue(tempNode, nodeType);
        int    position    = 1;
  
        tempNode = getPreviousTypedNode(tempNode, nodeType);
  
        while (tempNode != null)
        {
          if (nodeType == Node.ELEMENT_NODE)
          {
            if (getValue(tempNode, nodeType).equals(targetValue))
            {
              position++;
            }
          }
          else
          {
            position++;
          }
  
          tempNode = getPreviousTypedNode(tempNode, nodeType);
        }
  
        boolean hasMatchingSiblings = (position > 1);
  
        if (!hasMatchingSiblings)
        {
          tempNode = (Node)path.elementAt(i);
          tempNode = getNextTypedNode(tempNode, nodeType);
  
          while (!hasMatchingSiblings && tempNode != null)
          {
            if (nodeType == Node.ELEMENT_NODE)
            {
              if (getValue(tempNode, nodeType).equals(targetValue))
              {
                hasMatchingSiblings = true;
              }
              else
              {
                tempNode = getNextTypedNode(tempNode, nodeType);
              }
            }
            else
            {
              hasMatchingSiblings = true;
            }
          }
        }
  
        String step;
  
        switch (nodeType)
        {
          case Node.TEXT_NODE :
            step = "text()";
            break;
          case Node.PROCESSING_INSTRUCTION_NODE :
            step = "processing-instruction()";
            break;
          default :
            step = targetValue;
            break;
        }
  
        if (step != null && step.length() > 0)
        {
          strBuf.append('/' + step);
        }
  
        if (hasMatchingSiblings)
        {
          strBuf.append("[" + position + "]");
        }
      }
  
      return strBuf.toString();
    }
  
    private static Vector getVectorPathFromNode(Node node)
    {
      Vector path = new Vector();
  
      while (node != null)
      {
        path.insertElementAt(node, 0);
        node = node.getParentNode();
      }
  
      return path;
    }
  
    /**
     * Generates an XPath expression that will return only the given node as its
     * result. This method only works for element, text, document and PI nodes.
     *
     * @param node the node to generate an XPath expression for. This node must
     * be an element node, a text node, a document node, or a processing
     * instruction node.
     * @return an XPath expression that will return only the given node as its
     * result.
     * @exception IllegalArgumentException if the given node is not an element,
     * text, document or PI node.
     */
    public static String getXPathExprFromNode(Node node)
                                                  throws IllegalArgumentException
    {
      short nodeType = getNodeType(node);
  
      switch (nodeType)
      {
        case Node.ELEMENT_NODE :
        case Node.TEXT_NODE :
        case Node.PROCESSING_INSTRUCTION_NODE :
          return getXPathFromVector(getVectorPathFromNode(node));
  
        case Node.DOCUMENT_NODE :
          return "/";
  
        default :
          throw new IllegalArgumentException("Only works for element, text, " +
                                             "document, and PI nodes.");
      }
    }
  }
  
  
  1.1                  xml-soap/java/src/org/apache/soap/util/xml/XercesParserLiaison.java
  
  Index: XercesParserLiaison.java
  ===================================================================
  /*
   * The Apache Software License, Version 1.1
   *
   *
   * Copyright (c) 2000 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 "Xerces" 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 org.apache.soap.util.xml;
  
  import java.io.*;
  import org.w3c.dom.*;
  import org.apache.xerces.dom.*;
  import org.apache.xerces.parsers.*;
  import org.xml.sax.*;
  
  /**
   * Implements XMLParserLiaison using The Apache XML Projects' Xerces parser.
   *
   * @author   Matthew J. Duftler
   * @author   Sanjiva Weerawarana
   * @author   Paco Curbera
   * @author   Joseph Kesselman
   * @see      XMLParserLiaison
   */
  public class XercesParserLiaison implements XMLParserLiaison
  {
    public Document read(String sourceDesc, Reader reader)
    {
      DOMParser parser = new DOMParser();
      InputSource in = new InputSource(reader);
  
      try
      {
        parser.setFeature("http://xml.org/sax/features/namespaces", true);
        parser.parse(in);
  
        return parser.getDocument();
      }
      catch (SAXException e)
      {
        e.printStackTrace();
        return null;
      }
      catch (IOException e)
      {
        e.printStackTrace();
        return null;
      }
    }
  
    public Document createDocument()
    {
      return new DocumentImpl();
    }
  }