axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: ws-axis/java/test/functional TestEncoding.java
Date Mon, 26 Apr 2004 11:51:44 GMT
dims        2004/04/26 04:51:44

  Modified:    java/src/org/apache/axis Message.java MessageContext.java
                        SOAPPart.java
               java/src/org/apache/axis/attachments AttachmentsImpl.java
                        ManagedMemoryDataSource.java
               java/src/org/apache/axis/client Stub.java
               java/src/org/apache/axis/components/encoding
                        AbstractXMLEncoder.java UTF16Encoder.java
                        UTF8Encoder.java XMLEncoder.java
               java/src/org/apache/axis/encoding DeserializerImpl.java
                        SerializationContextImpl.java
               java/src/org/apache/axis/utils Mapping.java NSStack.java
                        XMLUtils.java
               java/test/encoding PackageTests.java TestString.java
               java/test/functional TestEncoding.java
  Added:       java/samples/perf PerfPortSoapBindingImpl.java
                        PerfService_ServiceTestCase.java build.xml
                        deploy.wsdd perf.wsdl
               java/src/org/apache/axis/utils ByteArray.java
               java/test/encoding TestString2.java
  Log:
  Spent a few days with Purify and Quantify:
  
  Performance Related:
  - Ensure that serialization stuff is called only once and avoid String<->byte[] conversions.
  - File backed Byte Array for large messages
  - cleanup encoder to avoid byte<->string conversions.
  - use intern's in NSStack/Mapping to reduce new object creation and speed up compares.
  
  Others:
  - file extensions for temp files clean up
  - clean up encoding stuff (check message, then context, then the axis engine for which encoding to use)
  
  Revision  Changes    Path
  1.1                  ws-axis/java/samples/perf/PerfPortSoapBindingImpl.java
  
  Index: PerfPortSoapBindingImpl.java
  ===================================================================
  /**
   * PerfPortSoapBindingImpl.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis 1.2beta Apr 25, 2004 (11:19:16 EDT) WSDL2Java emitter.
   */
  
  package samples.perf;
  
  public class PerfPortSoapBindingImpl implements samples.perf.PerfService_Port{
      public java.lang.String handleStringArray(java.lang.String[] s) throws java.rmi.RemoteException {
          String returnString;
          returnString = "array length was - " + s.length;
          return returnString;
      }
  
  }
  
  
  
  1.1                  ws-axis/java/samples/perf/PerfService_ServiceTestCase.java
  
  Index: PerfService_ServiceTestCase.java
  ===================================================================
  /**
   * PerfService_ServiceTestCase.java
   *
   * This file was auto-generated from WSDL
   * by the Apache Axis 1.2beta Apr 25, 2004 (11:19:16 EDT) WSDL2Java emitter.
   */
  
  package samples.perf;
  
  import java.util.Date;
  import org.apache.axis.components.logger.LogFactory;
  import org.apache.commons.logging.Log;
  
  public class PerfService_ServiceTestCase extends junit.framework.TestCase {
      /** Field log */
      static Log log = LogFactory.getLog(PerfService_ServiceTestCase.class.getName());
  
      public PerfService_ServiceTestCase(java.lang.String name) {
          super(name);
      }
  
      public void test1PerfPortHandleStringArray() throws Exception {
          samples.perf.PerfPortSoapBindingStub binding;
          try {
              binding = (samples.perf.PerfPortSoapBindingStub)
                            new samples.perf.PerfService_ServiceLocator().getPerfPort();
          }
          catch (javax.xml.rpc.ServiceException jre) {
              if(jre.getLinkedCause()!=null)
                  jre.getLinkedCause().printStackTrace();
              throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught: " + jre);
          }
          assertNotNull("binding is null", binding);
  
          // Time out after a minute
          binding.setTimeout(60000);
          binding._setProperty(org.apache.axis.client.Call.STREAMING_PROPERTY, Boolean.TRUE);
          // Time out after a minute
          binding.setTimeout(60000);
  
          log.info(">>>> Warming up...");
          pump(binding, 1);
          log.info(">>>> Running volume tests...");
          pump(binding, 100);
          pump(binding, 1000);
          pump(binding, 10000);
          pump(binding, 100000);
      }
  
      private static void pump(PerfPortSoapBindingStub binding, int count)
              throws java.rmi.RemoteException {
          String[] s = new String[count];
          for (int i = 0; i < s.length; i++) {
              s[i] = "qwertyuiopåasdfghjklöäzxcvbnm";
          }
          Date start = new Date();
          String value = binding.handleStringArray(s);
          Date end = new Date();
  
          log.info("Count:" + count + " \tTime consumed: " +
                  (end.getTime() - start.getTime()) + "\tReturn:" + value);
      }
  
  }
  
  
  
  1.1                  ws-axis/java/samples/perf/build.xml
  
  Index: build.xml
  ===================================================================
  <?xml version="1.0" ?>
  <!DOCTYPE project [
          <!ENTITY properties SYSTEM "file:../../xmls/properties.xml">
          <!ENTITY paths  SYSTEM "file:../../xmls/path_refs.xml">
          <!ENTITY taskdefs SYSTEM "file:../../xmls/taskdefs.xml">
          <!ENTITY taskdefs_post_compile SYSTEM "file:../../xmls/taskdefs_post_compile.xml">
          <!ENTITY targets SYSTEM "file:../../xmls/targets.xml">
  ]>
  
  <!-- ===================================================================
  <description>
     Test/Sample Component file for Axis
  
  Notes:
     This is a build file for use with the Jakarta Ant build tool.
  
  Prerequisites:
  
     jakarta-ant from http://jakarta.apache.org
  
  Build Instructions:
     To compile
          ant compile
     To execute
          ant run
  
  Author:
    Matt Seibert mseibert@us.ibm.com
  
  Copyright:
    Copyright (c) 2002-2003 Apache Software Foundation.
  </description>
  ==================================================================== -->
  
  <project default="compile">
  
      <property name="axis.home" location="../.."/>
      <property name="componentName" value="samples/perf"/>
      &properties;
      &paths;
      &taskdefs;
      &taskdefs_post_compile;
      &targets;
  
      <target name="clean">
          <echo message="Removing ${build.dir}/classes/${componentName} and ${build.dir}/work/${componentName}"/>
          <delete dir="${build.dir}/classes/${componentName}"/>
          <delete dir="${build.dir}/work/${componentName}"/>
      </target>
  
      <target name="copy" depends="setenv"/>
  
      <target name="compile" depends="copy">
          <echo message="Compiling samples.perf"/>
  
          <wsdl2java url="${axis.home}/samples/perf/perf.wsdl"
              output="${axis.home}/build/work"
              serverSide="yes"
              testcase="yes">
          </wsdl2java>
  
          <copy todir="${build.dir}/work/samples/perf" overwrite="yes">
              <fileset dir="${axis.home}/samples/perf">
                  <include name="*Test*.java"/>
                  <include name="*Impl.java"/>
                  <include name="*.wsdd"/>
              </fileset>
          </copy>
  
          <javac srcdir="${build.dir}/work" destdir="${build.dest}" debug="${debug}" nowarn="${nowarn}" fork="${javac.fork}">
              <classpath refid="classpath"/>
              <include name="samples/perf/*.java"/>
          </javac>
      </target>
  
      <target name="run">
          <antcall target="execute-Component"/>
      </target>
  
  </project>
  
  
  
  1.1                  ws-axis/java/samples/perf/deploy.wsdd
  
  Index: deploy.wsdd
  ===================================================================
  <!-- Use this file to deploy some handlers/chains and services      -->
  <!-- Two ways to do this:                                           -->
  <!--   java org.apache.axis.client.AdminClient deploy.wsdd          -->
  <!--      after the axis server is running                          -->
  <!-- or                                                             -->
  <!--   java org.apache.axis.utils.Admin client|server deploy.wsdd   -->
  <!--      from the same directory that the Axis engine runs         -->
  
  <deployment
      xmlns="http://xml.apache.org/axis/wsdd/"
      xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  
    <!-- Services from PerfService WSDL service -->
  
    <service name="PerfPort" provider="java:RPC" style="rpc" use="encoded" streaming="on">
        <parameter name="wsdlTargetNamespace" value="http://perf.samples"/>
        <parameter name="wsdlServiceElement" value="PerfService"/>
        <parameter name="wsdlServicePort" value="PerfPort"/>
        <parameter name="className" value="samples.perf.PerfPortSoapBindingImpl"/>
        <parameter name="wsdlPortType" value="PerfService"/>
        <operation name="handleStringArray" qname="operNS:handleStringArray" xmlns:operNS="http://perf.samples" returnQName="handleStringArrayReturn" returnType="rtns:string" xmlns:rtns="http://schemas.xmlsoap.org/soap/encoding/" soapAction="" >
          <parameter name="s" type="tns:ArrayOf_xsd_string" xmlns:tns="http://perf.samples"/>
        </operation>
        <parameter name="allowedMethods" value="handleStringArray"/>
  
        <typeMapping
          xmlns:ns="http://perf.samples"
          qname="ns:ArrayOf_xsd_string"
          type="java:java.lang.String[]"
          serializer="org.apache.axis.encoding.ser.ArraySerializerFactory"
          deserializer="org.apache.axis.encoding.ser.ArrayDeserializerFactory"
          encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
        />
    </service>
  </deployment>
  
  
  
  1.1                  ws-axis/java/samples/perf/perf.wsdl
  
  Index: perf.wsdl
  ===================================================================
  <wsdl:definitions targetNamespace="http://perf.samples" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://perf.samples" xmlns:intf="http://perf.samples" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <!--WSDL created by Apache Axis version: 1.2beta
  Built on Apr 25, 2004 (11:19:16 EDT)-->
   <wsdl:types>
    <schema targetNamespace="http://perf.samples" xmlns="http://www.w3.org/2001/XMLSchema">
     <import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
     <complexType name="ArrayOf_xsd_string">
      <complexContent>
       <restriction base="soapenc:Array">
        <attribute ref="soapenc:arrayType" wsdl:arrayType="xsd:string[]"/>
       </restriction>
  
      </complexContent>
     </complexType>
    </schema>
   </wsdl:types>
   <wsdl:message name="handleStringArrayResponse">
    <wsdl:part name="handleStringArrayReturn" type="soapenc:string"/>
   </wsdl:message>
   <wsdl:message name="handleStringArrayRequest">
    <wsdl:part name="s" type="impl:ArrayOf_xsd_string"/>
  
   </wsdl:message>
   <wsdl:portType name="PerfService">
    <wsdl:operation name="handleStringArray" parameterOrder="s">
     <wsdl:input message="impl:handleStringArrayRequest" name="handleStringArrayRequest"/>
     <wsdl:output message="impl:handleStringArrayResponse" name="handleStringArrayResponse"/>
    </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="PerfPortSoapBinding" type="impl:PerfService">
    <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
  
    <wsdl:operation name="handleStringArray">
     <wsdlsoap:operation soapAction=""/>
     <wsdl:input name="handleStringArrayRequest">
      <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://perf.samples" use="encoded"/>
     </wsdl:input>
     <wsdl:output name="handleStringArrayResponse">
      <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://perf.samples" use="encoded"/>
     </wsdl:output>
    </wsdl:operation>
  
   </wsdl:binding>
   <wsdl:service name="PerfService">
    <wsdl:port binding="impl:PerfPortSoapBinding" name="PerfPort">
     <wsdlsoap:address location="http://localhost:8080/axis/services/PerfPort"/>
    </wsdl:port>
   </wsdl:service>
  </wsdl:definitions>
  
  
  
  1.114     +5 -19     ws-axis/java/src/org/apache/axis/Message.java
  
  Index: Message.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/Message.java,v
  retrieving revision 1.113
  retrieving revision 1.114
  diff -u -r1.113 -r1.114
  --- Message.java	22 Apr 2004 18:00:12 -0000	1.113
  +++ Message.java	26 Apr 2004 11:51:43 -0000	1.114
  @@ -461,19 +461,8 @@
               }
           }
   
  -        // The origional logic is very simple
  -        // String ret = sc.getContentType() + "; charset="+XMLUtils.getEncoding().toLowerCase();
  -        // The following logic is devised to utilize CHARACTER_SET_ENCODING property from SAAJ 1.2.
  -        String encoding = null;
  -        try {
  -            encoding = (String) getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  -        } catch (SOAPException e) {
  -        }
  -        if (encoding == null) {
  -            encoding = XMLUtils.getEncoding().toLowerCase();
  -        }
  -
  -        String ret = sc.getContentType() + "; charset=" + encoding;
  +        String encoding = XMLUtils.getEncoding(this, msgContext);;
  +        String ret = sc.getContentType() + "; charset=" + encoding.toLowerCase();
           
           // Support of SOAP 1.2 HTTP binding
           if (soap12) {
  @@ -495,7 +484,7 @@
        *              the length being calculated
        */
       public long getContentLength() throws org.apache.axis.AxisFault {
  -        long ret = mSOAPPart.getAsBytes().length;
  +        long ret = mSOAPPart.getContentLength();
           if (mAttachments != null && 0 < mAttachments.getAttachmentCount()) {
               ret = mAttachments.getContentLength();
           }
  @@ -522,10 +511,7 @@
            //Do it the old fashion way.
           if (mAttachments == null || 0 == mAttachments.getAttachmentCount()) {
               try {
  -                String charEncoding = (String)getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  -                if(charEncoding == null){
  -                    charEncoding = "UTF-8";
  -                }
  +                String charEncoding = XMLUtils.getEncoding(this, msgContext);;
                   // write the xml declaration header
                   String incXMLDecl = (String)getProperty(SOAPMessage.WRITE_XML_DECLARATION);
                   if(incXMLDecl == null){
  @@ -622,7 +608,7 @@
           saveRequired = false;
           try {
               /* Fix for Bug 16418 - Start from scratch */ 
  -            getSOAPPartAsString();
  +            mSOAPPart.saveChanges();
           } catch (AxisFault axisFault) {
               log.error(Messages.getMessage("exception00"), axisFault);
           }
  
  
  
  1.143     +1 -1      ws-axis/java/src/org/apache/axis/MessageContext.java
  
  Index: MessageContext.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/MessageContext.java,v
  retrieving revision 1.142
  retrieving revision 1.143
  diff -u -r1.142 -r1.143
  --- MessageContext.java	20 Apr 2004 12:07:31 -0000	1.142
  +++ MessageContext.java	26 Apr 2004 11:51:43 -0000	1.143
  @@ -316,7 +316,7 @@
               try {
                   //or create and delete a file in the temp dir to make
                   //sure we have write access to it.
  -                File tf= File.createTempFile("Axis", "Axis");
  +                File tf= File.createTempFile("Axis", ".tmp");
                   File dir= tf.getParentFile();
                   if (tf.exists()) {
                       tf.delete();
  
  
  
  1.66      +125 -91   ws-axis/java/src/org/apache/axis/SOAPPart.java
  
  Index: SOAPPart.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/SOAPPart.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- SOAPPart.java	22 Apr 2004 18:00:12 -0000	1.65
  +++ SOAPPart.java	26 Apr 2004 11:51:43 -0000	1.66
  @@ -21,51 +21,53 @@
   import org.apache.axis.encoding.DeserializationContextImpl;
   import org.apache.axis.encoding.SerializationContextImpl;
   import org.apache.axis.message.InputStreamBody;
  +import org.apache.axis.message.MimeHeaders;
   import org.apache.axis.message.SOAPDocumentImpl;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.message.SOAPHeaderElement;
  -import org.apache.axis.message.MimeHeaders;
   import org.apache.axis.transport.http.HTTPConstants;
  +import org.apache.axis.utils.ByteArray;
   import org.apache.axis.utils.Messages;
   import org.apache.axis.utils.SessionUtils;
  +import org.apache.axis.utils.XMLUtils;
   import org.apache.commons.logging.Log;
  -import org.xml.sax.InputSource;
  -import org.xml.sax.SAXException;
  +import org.w3c.dom.Attr;
  +import org.w3c.dom.CDATASection;
  +import org.w3c.dom.Comment;
  +import org.w3c.dom.DOMException;
   import org.w3c.dom.DOMImplementation;
  +import org.w3c.dom.Document;
   import org.w3c.dom.DocumentFragment;
   import org.w3c.dom.DocumentType;
   import org.w3c.dom.Element;
  -import org.w3c.dom.Attr;
  -import org.w3c.dom.DOMException;
  -import org.w3c.dom.CDATASection;
  -import org.w3c.dom.Comment;
   import org.w3c.dom.EntityReference;
  +import org.w3c.dom.NamedNodeMap;
   import org.w3c.dom.Node;
   import org.w3c.dom.NodeList;
  -import org.w3c.dom.Text;
   import org.w3c.dom.ProcessingInstruction;
  -import org.w3c.dom.Document;
  -import org.w3c.dom.NamedNodeMap;
  +import org.w3c.dom.Text;
  +import org.xml.sax.InputSource;
  +import org.xml.sax.SAXException;
   
   import javax.xml.soap.SOAPException;
   import javax.xml.soap.SOAPMessage;
   import javax.xml.transform.Source;
   import javax.xml.transform.dom.DOMSource;
   import javax.xml.transform.stream.StreamSource;
  +import java.io.BufferedOutputStream;
  +import java.io.BufferedReader;
  +import java.io.BufferedWriter;
  +import java.io.ByteArrayInputStream;
   import java.io.ByteArrayOutputStream;
   import java.io.IOException;
   import java.io.InputStream;
  +import java.io.OutputStreamWriter;
  +import java.io.PrintWriter;
  +import java.io.Reader;
   import java.io.StringReader;
   import java.io.StringWriter;
   import java.io.UnsupportedEncodingException;
   import java.io.Writer;
  -import java.io.Reader;
  -import java.io.BufferedReader;
  -import java.io.ByteArrayInputStream;
  -import java.io.PrintWriter;
  -import java.io.OutputStreamWriter;
  -import java.io.BufferedWriter;
  -import java.io.BufferedOutputStream;
   import java.util.Iterator;
   import java.util.Vector;
   
  @@ -96,6 +98,7 @@
       public static final int FORM_BYTES        = 4;
       public static final int FORM_BODYINSTREAM = 5;
       public static final int FORM_FAULT        = 6;
  +    public static final int FORM_OPTIMIZED    = 7;
       private int currentForm;
   
       //private Hashtable headers = new Hashtable();
  @@ -210,14 +213,17 @@
        *
        * @return the content length in bytes
        */
  -    public int getContentLength() {
  -        try {
  -            byte[] bytes = this.getAsBytes();
  -            return bytes.length;
  -        } catch (AxisFault fault) {
  -            return 0;  // ?
  +    public long getContentLength() throws AxisFault {
  +        saveChanges();
  +        if (currentForm == FORM_OPTIMIZED) {
  +            return ((ByteArray) currentMessage).size();
  +        } else if (currentForm == FORM_BYTES) {
  +            return ((byte[]) currentMessage).length;
           }
  +        byte[] bytes = this.getAsBytes();
  +        return bytes.length;
       }
  +
       /**
        * This set the SOAP Envelope for this part.
        * <p>
  @@ -236,19 +242,6 @@
       }
   
       /**
  -     * Get the total size in bytes, including headers, of this Part.
  -     * TODO: For now, since we aren't actually doing MIME yet,
  -     * this is the same as getContentLength().  Soon it will be
  -     * different.
  -     *
  -     * @return the total size
  -     */
  -    public int getSize() {
  -        // for now, we don't ever do headers!  ha ha
  -        return this.getContentLength();
  -    }
  -
  -    /**
        * Write the contents to the specified stream.
        *
        * @param os  the <code>java.io.OutputStream</code> to write to
  @@ -263,10 +256,16 @@
                           "\"?>").getBytes());
               }
               os.write((byte[])currentMessage);
  +        } else if ( currentForm == FORM_OPTIMIZED ) {
  +            if (incXMLDecl.equalsIgnoreCase("true")) {
  +                os.write(("<?xml version=\"1.0\" encoding=\"" + charEncoding +
  +                        "\"?>").getBytes());
  +            }
  +            ((ByteArray) currentMessage).writeTo(os);
  +            ((ByteArray) currentMessage).discardBuffer();
           } else {
               Writer writer = new OutputStreamWriter(os,charEncoding);
  -            writer = new BufferedWriter(writer);
  -            writer = new PrintWriter(new BufferedWriter(writer));
  +            writer = new BufferedWriter(new PrintWriter(writer));
       
               if(incXMLDecl.equalsIgnoreCase("true")){
                   writer.write("<?xml version=\"1.0\" encoding=\"" + charEncoding +"\"?>");
  @@ -367,6 +366,14 @@
        */
       public byte[] getAsBytes() throws AxisFault {
           log.debug("Enter: SOAPPart::getAsBytes");
  +        if ( currentForm == FORM_OPTIMIZED ) {
  +            log.debug("Exit: SOAPPart::getAsBytes");
  +            try {
  +                return ((ByteArray) currentMessage).toByteArray();
  +            } catch (IOException e) {
  +                throw AxisFault.makeFault(e);
  +            }
  +        }
           if ( currentForm == FORM_BYTES ) {
               log.debug("Exit: SOAPPart::getAsBytes");
               return (byte[])currentMessage;
  @@ -413,29 +420,20 @@
   
           if ( currentForm == FORM_SOAPENVELOPE ||
                currentForm == FORM_FAULT ){
  -            String encoding = null;
  -            if (msgObject != null) {
  -                try {
  -                    encoding = (String) msgObject.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  -                } catch (SOAPException e) {
  -                }
  -            }
  -            if (encoding == null) {
  -                encoding = "UTF-8";
  -            }
  +            String encoding = XMLUtils.getEncoding(msgObject, null);
               ByteArrayOutputStream baos = new ByteArrayOutputStream();
               BufferedOutputStream os = new BufferedOutputStream(baos);
               try {
  -                this.writeTo(os,encoding,"false");
  +                this.writeTo(os, encoding, "false");
                   os.flush();
               } catch (Exception e) {
                   throw AxisFault.makeFault(e);
               }
  -            setCurrentForm( baos.toByteArray(), FORM_BYTES );
  +            setCurrentForm(baos.toByteArray(), FORM_BYTES);
               if (log.isDebugEnabled()) {
                   log.debug("Exit: SOAPPart::getAsBytes(): " + currentMessage);
               }
  -            return (byte[])currentMessage;
  +            return (byte[]) currentMessage;
           }
   
           if ( currentForm == FORM_STRING ) {
  @@ -452,17 +450,7 @@
               // Save this message in case it is requested later in getAsString
               currentMessageAsString = (String) currentMessage;
               try{
  -                // set encoding of string from parent.
  -                String encoding = null;
  -                if (msgObject != null) {
  -                    try {
  -                        encoding = (String) msgObject.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  -                    } catch (SOAPException e) {
  -                    }
  -                }
  -                if (encoding == null) {
  -                    encoding = "UTF-8";
  -                }
  +                String encoding = XMLUtils.getEncoding(msgObject, null);
                   setCurrentForm( ((String)currentMessage).getBytes(encoding),
                       FORM_BYTES );
               }catch(UnsupportedEncodingException ue){
  @@ -481,6 +469,24 @@
           return null;
       }
   
  +    public void saveChanges() throws AxisFault {
  +        log.debug("Enter: SOAPPart::saveChanges");
  +        if ( currentForm == FORM_SOAPENVELOPE ||
  +             currentForm == FORM_FAULT ){
  +            String encoding = XMLUtils.getEncoding(msgObject, null);
  +            ByteArray array = new ByteArray();
  +            try {
  +                this.writeTo(array,encoding,"false");
  +                array.flush();
  +            } catch (Exception e) {
  +                throw AxisFault.makeFault(e);
  +            }
  +            setCurrentForm( array, FORM_OPTIMIZED );
  +            if (log.isDebugEnabled()) {
  +                log.debug("Exit: SOAPPart::saveChanges(): " + currentMessage);
  +            }
  +        }
  +    }
       /**
        * Get the contents of this Part (not the headers!), as a String.
        * This will force buffering of the message.
  @@ -503,6 +509,27 @@
               // Fall thru to "Bytes"
           }
   
  +        if ( currentForm == FORM_OPTIMIZED) {
  +            try {
  +                currentMessageAsBytes =
  +                        ((ByteArray) currentMessage).toByteArray();
  +            } catch (IOException e) {
  +                throw AxisFault.makeFault(e);
  +            }
  +
  +            try{
  +                setCurrentForm( new String((byte[]) currentMessageAsBytes,"UTF-8"),
  +                                   FORM_STRING );
  +            }catch(UnsupportedEncodingException ue){
  +                setCurrentForm( new String((byte[]) currentMessageAsBytes),
  +                                   FORM_STRING );
  +            }
  +            if (log.isDebugEnabled()) {
  +                log.debug("Exit: SOAPPart::getAsString(): " + currentMessage);
  +            }
  +            return (String)currentMessage;
  +        }
  +
           if ( currentForm == FORM_BYTES ) {
               // If the current message was already converted from
               // a String to byte[], return the String representation
  @@ -514,6 +541,7 @@
                   }
                   return currentMessageAsString;
               }
  +            
               // Save this message in case it is requested later in getAsBytes
               currentMessageAsBytes = (byte[]) currentMessage;
               try{
  @@ -597,14 +625,7 @@
   
           if ( currentForm == FORM_INPUTSTREAM ) {
               is = new InputSource( (InputStream) currentMessage );
  -            // set encoding of input source from parent.
  -            String encoding = null;
  -            if (msgObject != null) {
  -                try {
  -                    encoding = (String) msgObject.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  -                } catch (SOAPException e) {
  -                }
  -            }
  +            String encoding = XMLUtils.getEncoding(msgObject, null);
               if (encoding != null) {
                   is.setEncoding(encoding);
               }
  @@ -795,28 +816,41 @@
       public Source getContent() throws SOAPException {
           if(contentSource == null) {
               switch(currentForm) {
  -            case FORM_STRING:
  -                String s = (String)currentMessage;
  -                contentSource = new StreamSource(new StringReader(s));
  -                break;
  -            case FORM_INPUTSTREAM:
  -                contentSource = new StreamSource((InputStream)currentMessage);
  -                break;
  -            case FORM_SOAPENVELOPE:
  -                SOAPEnvelope se = (SOAPEnvelope)currentMessage;
  -                try {
  -                    contentSource = new DOMSource(se.getAsDocument());
  -                } catch (Exception e) {
  -                    throw new SOAPException(Messages.getMessage("errorGetDocFromSOAPEnvelope"), e);
  -                }
  -                break;
  -            case FORM_BYTES:
  -                byte[] bytes = (byte[])currentMessage;
  -                contentSource = new StreamSource(new ByteArrayInputStream(bytes));
  -                break;
  +                case FORM_STRING:
  +                    String s = (String) currentMessage;
  +                    contentSource = new StreamSource(new StringReader(s));
  +                    break;
  +                case FORM_INPUTSTREAM:
  +                    contentSource =
  +                            new StreamSource((InputStream) currentMessage);
  +                    break;
  +                case FORM_SOAPENVELOPE:
  +                    SOAPEnvelope se = (SOAPEnvelope) currentMessage;
  +                    try {
  +                        contentSource = new DOMSource(se.getAsDocument());
  +                    } catch (Exception e) {
  +                        throw new SOAPException(Messages.getMessage("errorGetDocFromSOAPEnvelope"),
  +                                e);
  +                    }
  +                    break;
  +                case FORM_OPTIMIZED:
  +                    try {
  +                        ByteArrayInputStream baos = new ByteArrayInputStream(((ByteArray) currentMessage).toByteArray());
  +                        contentSource = new StreamSource(baos);
  +                    } catch (IOException e) {
  +                        throw new SOAPException(Messages.getMessage("errorGetDocFromSOAPEnvelope"),
  +                                e);
  +                    }
  +                    break;
  +                case FORM_BYTES:
  +                    byte[] bytes = (byte[]) currentMessage;
  +                    contentSource =
  +                            new StreamSource(new ByteArrayInputStream(bytes));
  +                    break;
                   case FORM_BODYINSTREAM:
  -                contentSource = new StreamSource((InputStream)currentMessage);
  -                break;
  +                    contentSource =
  +                            new StreamSource((InputStream) currentMessage);
  +                    break;
               }
           }
           return contentSource;
  
  
  
  1.48      +1 -1      ws-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java
  
  Index: AttachmentsImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/attachments/AttachmentsImpl.java,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- AttachmentsImpl.java	22 Apr 2004 18:00:12 -0000	1.47
  +++ AttachmentsImpl.java	26 Apr 2004 11:51:43 -0000	1.48
  @@ -516,7 +516,7 @@
   
               // force a serialization of the message so that
               // any attachments will be added
  -            soapPart.getAsBytes();
  +            soapPart.saveChanges();
               
               return orderedAttachments.size();
           } catch (AxisFault e) {
  
  
  
  1.34      +1 -1      ws-axis/java/src/org/apache/axis/attachments/ManagedMemoryDataSource.java
  
  Index: ManagedMemoryDataSource.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/attachments/ManagedMemoryDataSource.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- ManagedMemoryDataSource.java	11 Apr 2004 11:07:28 -0000	1.33
  +++ ManagedMemoryDataSource.java	26 Apr 2004 11:51:43 -0000	1.34
  @@ -385,7 +385,7 @@
                               : mc.getStrProp(
                                       MessageContext.ATTACHMENTS_DIR);
   
  -                    diskCacheFile = java.io.File.createTempFile("Axis", "axis",
  +                    diskCacheFile = java.io.File.createTempFile("Axis", ".att",
                               (attdir == null)
                               ? null
                               : new File(
  
  
  
  1.36      +1 -2      ws-axis/java/src/org/apache/axis/client/Stub.java
  
  Index: Stub.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/client/Stub.java,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -r1.35 -r1.36
  --- Stub.java	8 Apr 2004 13:09:05 -0000	1.35
  +++ Stub.java	26 Apr 2004 11:51:43 -0000	1.36
  @@ -289,8 +289,7 @@
        */ 
       public void extractAttachments(Call call) {
           attachments.clear();
  -        if(call.getResponseMessage() != null &&
  -           call.getResponseMessage().countAttachments()>0) {
  +        if(call.getResponseMessage() != null) {
               Iterator iterator = call.getResponseMessage().getAttachments();
               while(iterator.hasNext()){
                   attachments.add(iterator.next());
  
  
  
  1.6       +17 -34    ws-axis/java/src/org/apache/axis/components/encoding/AbstractXMLEncoder.java
  
  Index: AbstractXMLEncoder.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/encoding/AbstractXMLEncoder.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AbstractXMLEncoder.java	25 Feb 2004 14:02:31 -0000	1.5
  +++ AbstractXMLEncoder.java	26 Apr 2004 11:51:43 -0000	1.6
  @@ -17,8 +17,6 @@
   
   import org.apache.axis.utils.Messages;
   
  -import java.io.UnsupportedEncodingException;
  -
   /**
    *
    * Abstract class for XML String encoders.
  @@ -33,13 +31,19 @@
    *
    */
   public abstract class AbstractXMLEncoder implements XMLEncoder {
  -    private static final byte[] AMP = "&amp;".getBytes();
  -    private static final byte[] QUOTE = "&quot;".getBytes();
  -    private static final byte[] LESS = "&lt;".getBytes();
  -    private static final byte[] GREATER = "&gt;".getBytes();
  -    private static final byte[] LF = "\n".getBytes();
  -    private static final byte[] CR = "\r".getBytes();
  -    private static final byte[] TAB = "\t".getBytes();
  +    protected static final String AMP = "&amp;";
  +    protected static final String QUOTE = "&quot;";
  +    protected static final String LESS = "&lt;";
  +    protected static final String GREATER = "&gt;";
  +    protected static final String LF = "\n";
  +    protected static final String CR = "\r";
  +    protected static final String TAB = "\t";
  +
  +    /**
  +     * gets the encoding supported by this encoder
  +     * @return string
  +     */
  +    public abstract String getEncoding();
   
       /**
        * Encode a string
  @@ -51,7 +55,7 @@
               return "";
           }
           char[] characters = xmlString.toCharArray();
  -        EncodedByteArray out = null;
  +        StringBuffer out = null;
           char character;
   
           for (int i = 0; i < characters.length; i++) {
  @@ -104,11 +108,6 @@
                   default:
                       if (character < 0x20) {
                           throw new IllegalArgumentException(Messages.getMessage("invalidXmlCharacter00", Integer.toHexString(character), xmlString));
  -                    } else if (needsEncoding(character)) {
  -                        if (out == null) {
  -                            out = getInitialByteArray(xmlString, i);
  -                        }
  -                        appendEncoded(out, character);
                       } else {
                           if (out != null) {
                               out.append(character);
  @@ -120,26 +119,10 @@
           if (out == null) {
               return xmlString;
           }
  -        try {
  -            return out.toString(getEncoding());
  -        } catch (UnsupportedEncodingException e) {
  -            // we tested it ealier, should work.
  -            throw new IllegalStateException(Messages.getMessage("encodingDisappeared00", getEncoding()));
  -        }
  +        return out.toString();
       }
   
  -    public abstract String getEncoding();
  -
  -    public abstract boolean needsEncoding(char c);
  -
  -    public abstract void appendEncoded(EncodedByteArray out, char c);
  -
  -    private EncodedByteArray getInitialByteArray(String aXmlString, int pos) {
  -        try {
  -            return new EncodedByteArray(aXmlString.getBytes(getEncoding()), 0, pos);
  -        } catch (UnsupportedEncodingException e) {
  -            // we tested it ealier, should work.
  -            throw new IllegalStateException(Messages.getMessage("encodingDisappeared00", getEncoding()));
  -        }
  +    protected StringBuffer getInitialByteArray(String aXmlString, int pos) {
  +        return new StringBuffer(aXmlString.substring(0, pos));
       }
   }
  
  
  
  1.3       +63 -11    ws-axis/java/src/org/apache/axis/components/encoding/UTF16Encoder.java
  
  Index: UTF16Encoder.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/encoding/UTF16Encoder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UTF16Encoder.java	25 Feb 2004 14:02:31 -0000	1.2
  +++ UTF16Encoder.java	26 Apr 2004 11:51:43 -0000	1.3
  @@ -15,28 +15,80 @@
    */
   package org.apache.axis.components.encoding;
   
  +import org.apache.axis.i18n.Messages;
  +
  +import java.io.IOException;
  +import java.io.Writer;
  +
   /**
    * UTF-16 Encoder.
  - *
  + * 
    * @author <a href="mailto:jens@void.fm">Jens Schumann</a>
  - *
    * @see <a href="http://encoding.org">encoding.org</a>
    * @see <a href="http://czyborra.com/utf/#UTF-16">UTF 16 explained</a>
  - *
    */
   class UTF16Encoder extends AbstractXMLEncoder {
  +    /**
  +     * gets the encoding supported by this encoder
  +     * @return string
  +     */
       public String getEncoding() {
           return XMLEncoderFactory.ENCODING_UTF_16;
       }
   
  -    public boolean needsEncoding(char c) {
  -        return c > 0xFFFF;
  -    }
  -
  -    public void appendEncoded(EncodedByteArray out, char c) {
  -        if (c > 0xFFFF) {
  -            out.append((0xD7C0 + (c >> 10)));
  -            out.append((0xDC00 | c & 0x3FF));
  +    /**
  +     * write the encoded version of a given string
  +     * 
  +     * @param writer    writer to write this string to
  +     * @param xmlString string to be encoded
  +     */
  +    public void writeEncoded(Writer writer, String xmlString)
  +            throws IOException {
  +        if (xmlString == null) {
  +            return;
  +        }
  +        char[] characters = xmlString.toCharArray();
  +        char character;
  +        for (int i = 0; i < characters.length; i++) {
  +            character = characters[i];
  +            switch (character) {
  +                // we don't care about single quotes since axis will
  +                // use double quotes anyway
  +                case '&':
  +                    writer.write(AMP);
  +                    break;
  +                case '"':
  +                    writer.write(QUOTE);
  +                    break;
  +                case '<':
  +                    writer.write(LESS);
  +                    break;
  +                case '>':
  +                    writer.write(GREATER);
  +                    break;
  +                case '\n':
  +                    writer.write(LF);
  +                    break;
  +                case '\r':
  +                    writer.write(CR);
  +                    break;
  +                case '\t':
  +                    writer.write(TAB);
  +                    break;
  +                default:
  +                    if (character < 0x20) {
  +                        throw new IllegalArgumentException(Messages.getMessage(
  +                                "invalidXmlCharacter00",
  +                                Integer.toHexString(character),
  +                                xmlString));
  +                    } else if (character > 0xFFFF) {
  +                        writer.write((0xD7C0 + (character >> 10)));
  +                        writer.write((0xDC00 | character & 0x3FF));
  +                    } else {
  +                        writer.write(character);
  +                    }
  +                    break;
  +            }
           }
       }
   }
  
  
  
  1.3       +83 -22    ws-axis/java/src/org/apache/axis/components/encoding/UTF8Encoder.java
  
  Index: UTF8Encoder.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/encoding/UTF8Encoder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UTF8Encoder.java	25 Feb 2004 14:02:31 -0000	1.2
  +++ UTF8Encoder.java	26 Apr 2004 11:51:43 -0000	1.3
  @@ -15,39 +15,100 @@
    */
   package org.apache.axis.components.encoding;
   
  +import org.apache.axis.i18n.Messages;
  +
  +import java.io.IOException;
  +import java.io.Writer;
  +
   /**
    * UTF-8 Encoder.
  - *
  + * 
    * @author <a href="mailto:jens@void.fm">Jens Schumann</a>
  - *
    * @see <a href="http://encoding.org">encoding.org</a>
    * @see <a href="http://czyborra.com/utf/#UTF-8">UTF 8 explained</a>
  - *
    */
   class UTF8Encoder extends AbstractXMLEncoder {
  +    /**
  +     * gets the encoding supported by this encoder
  +     * 
  +     * @return string
  +     */
       public String getEncoding() {
           return XMLEncoderFactory.ENCODING_UTF_8;
       }
   
  -    public boolean needsEncoding(char c) {
  -        return c > 0x7F;
  -    }
  -
  -    public void appendEncoded(EncodedByteArray out, char c) {
  -        if (c < 0x80) {
  -            out.append(c);
  -        } else if (c < 0x800) {
  -            out.append((0xC0 | c >> 6));
  -            out.append((0x80 | c & 0x3F));
  -        } else if (c < 0x10000) {
  -            out.append((0xE0 | c >> 12));
  -            out.append((0x80 | c >> 6 & 0x3F));
  -            out.append((0x80 | c & 0x3F));
  -        } else if (c < 0x200000) {
  -            out.append((0xF0 | c >> 18));
  -            out.append((0x80 | c >> 12 & 0x3F));
  -            out.append((0x80 | c >> 6 & 0x3F));
  -            out.append((0x80 | c & 0x3F));
  +    /**
  +     * write the encoded version of a given string
  +     * 
  +     * @param writer    writer to write this string to
  +     * @param xmlString string to be encoded
  +     */
  +    public void writeEncoded(Writer writer, String xmlString)
  +            throws IOException {
  +        if (xmlString == null) {
  +            return;
  +        }
  +        char[] characters = xmlString.toCharArray();
  +        char character;
  +        for (int i = 0; i < characters.length; i++) {
  +            character = characters[i];
  +            switch (character) {
  +                // we don't care about single quotes since axis will
  +                // use double quotes anyway
  +                case '&':
  +                    writer.write(AMP);
  +                    break;
  +                case '"':
  +                    writer.write(QUOTE);
  +                    break;
  +                case '<':
  +                    writer.write(LESS);
  +                    break;
  +                case '>':
  +                    writer.write(GREATER);
  +                    break;
  +                case '\n':
  +                    writer.write(LF);
  +                    break;
  +                case '\r':
  +                    writer.write(CR);
  +                    break;
  +                case '\t':
  +                    writer.write(TAB);
  +                    break;
  +                default:
  +                    if (character < 0x20) {
  +                        throw new IllegalArgumentException(Messages.getMessage(
  +                                "invalidXmlCharacter00",
  +                                Integer.toHexString(character),
  +                                xmlString));
  +                    } else if (character > 0x7F) {
  +                        writer.write("&#x");
  +                        writer.write(Integer.toHexString(character).toUpperCase());
  +                        writer.write(";");
  +                        /*
  +			TODO: Try fixing this block instead of code above.
  +                        if (character < 0x80) {
  +                            writer.write(character);
  +                        } else if (character < 0x800) {
  +                            writer.write((0xC0 | character >> 6));
  +                            writer.write((0x80 | character & 0x3F));
  +                        } else if (character < 0x10000) {
  +                            writer.write((0xE0 | character >> 12));
  +                            writer.write((0x80 | character >> 6 & 0x3F));
  +                            writer.write((0x80 | character & 0x3F));
  +                        } else if (character < 0x200000) {
  +                            writer.write((0xF0 | character >> 18));
  +                            writer.write((0x80 | character >> 12 & 0x3F));
  +                            writer.write((0x80 | character >> 6 & 0x3F));
  +                            writer.write((0x80 | character & 0x3F));
  +                        }
  +                        */
  +                    } else {
  +                        writer.write(character);
  +                    }
  +                    break;
  +            }
           }
       }
   }
  
  
  
  1.3       +13 -2     ws-axis/java/src/org/apache/axis/components/encoding/XMLEncoder.java
  
  Index: XMLEncoder.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/components/encoding/XMLEncoder.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XMLEncoder.java	25 Feb 2004 14:02:31 -0000	1.2
  +++ XMLEncoder.java	26 Apr 2004 11:51:43 -0000	1.3
  @@ -15,13 +15,16 @@
    */
   package org.apache.axis.components.encoding;
   
  +import java.io.Writer;
  +import java.io.IOException;
  +
   /**
    * Interface for XMLEncoders
    */
   public interface XMLEncoder {
       /**
        * gets the encoding supported by this encoder
  -     * @return
  +     * @return string
        */
       public String getEncoding();
   
  @@ -30,5 +33,13 @@
        * @param xmlString string to be encoded
        * @return encoded string
        */
  -    String encode(String xmlString);
  +    public String encode(String xmlString);
  +
  +    /**
  +     * write the encoded version of a given string
  +     * @param writer writer to write this string to
  +     * @param xmlString string to be encoded
  +     */
  +    public void writeEncoded(Writer writer, String xmlString)
  +            throws IOException;
   }
  
  
  
  1.40      +0 -1      ws-axis/java/src/org/apache/axis/encoding/DeserializerImpl.java
  
  Index: DeserializerImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/DeserializerImpl.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- DeserializerImpl.java	25 Feb 2004 14:02:35 -0000	1.39
  +++ DeserializerImpl.java	26 Apr 2004 11:51:43 -0000	1.40
  @@ -542,7 +542,6 @@
           if (this.getClass().equals(DeserializerImpl.class) &&
               targets != null &&
               !targets.isEmpty()) {
  -
               StringWriter writer = new StringWriter();
               SerializationContextImpl serContext = 
                           new SerializationContextImpl(writer,
  
  
  
  1.107     +29 -22    ws-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
  
  Index: SerializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v
  retrieving revision 1.106
  retrieving revision 1.107
  diff -u -r1.106 -r1.107
  --- SerializationContextImpl.java	18 Apr 2004 18:07:36 -0000	1.106
  +++ SerializationContextImpl.java	26 Apr 2004 11:51:43 -0000	1.107
  @@ -39,6 +39,7 @@
   import org.apache.axis.attachments.Attachments;
   import org.apache.axis.client.Call;
   import org.apache.axis.components.logger.LogFactory;
  +import org.apache.axis.components.encoding.XMLEncoder;
   import org.apache.axis.description.OperationDesc;
   import org.apache.axis.description.TypeDesc;
   import org.apache.axis.encoding.ser.BaseSerializerFactory;
  @@ -131,7 +132,8 @@
       private int multiRefIndex = -1;
       private boolean noNamespaceMappings = true;
       private QName writeXMLType;
  -
  +    private XMLEncoder encoder = null;
  +    
       class MultiRefItem {
           String id;
           QName xmlType;
  @@ -194,6 +196,8 @@
                                 Constants.NS_PREFIX_SCHEMA_XSD);
           preferredPrefixes.put(schemaVersion.getXsiURI(),
                                 Constants.NS_PREFIX_SCHEMA_XSI);
  +        preferredPrefixes.put(soapConstants.getEnvelopeURI(),
  +                              Constants.NS_PREFIX_SOAP_ENV);
       }
   
   
  @@ -462,10 +466,7 @@
           if ((prefix == null) || (prefix.length() == 0))
              return qName.getLocalPart();
   
  -        StringBuffer sb = new StringBuffer(prefix);
  -        sb.append(':');
  -        sb.append(qName.getLocalPart());
  -        return sb.toString();
  +        return prefix + ':' + qName.getLocalPart();
       }
   
       public String qName2String(QName qName)
  @@ -484,18 +485,15 @@
        */
       public String attributeQName2String(QName qName) {
           String prefix = null;
  -
  -        if (qName.getNamespaceURI().length() > 0) {
  -            prefix = getPrefixForURI(qName.getNamespaceURI(), null, true);
  +        String uri = qName.getNamespaceURI(); 
  +        if (uri.length() > 0) {
  +            prefix = getPrefixForURI(uri, null, true);
           }
   
           if ((prefix == null) || (prefix.length() == 0))
              return qName.getLocalPart();
  -
  -        StringBuffer sb = new StringBuffer(prefix);
  -        sb.append(':');
  -        sb.append(qName.getLocalPart());
  -        return sb.toString();
  +        
  +        return prefix + ':' + qName.getLocalPart();
       }
   
       /**
  @@ -862,13 +860,7 @@
               // The origional logic is very simple
               // writer.write(XMLUtils.getEncoding());
               // The following logic is devised to utilize CHARACTER_SET_ENCODING property from SAAJ 1.2.
  -            String encoding = null;
  -            if (msgContext != null) {
  -                encoding = (String) msgContext.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  -            }
  -            if (encoding == null) {
  -                encoding = XMLUtils.getEncoding();
  -            }
  +            String encoding = XMLUtils.getEncoding(msgContext);
               writer.write(encoding);
               writer.write("\"?>\n");
               startOfDocument = false;
  @@ -928,7 +920,9 @@
                   }
                   writer.write(qname);
                   writer.write("=\"");
  -                writer.write(XMLUtils.xmlEncodeString(attributes.getValue(i)));
  +                
  +                getEncoder().writeEncoded(writer, attributes.getValue(i));
  +                
                   writer.write('"');
               }
           }
  @@ -1038,7 +1032,13 @@
       public void writeSafeString(String string)
           throws IOException
       {
  -        writeString(XMLUtils.xmlEncodeString(string));
  +        if (writingStartTag) {
  +            writer.write('>');
  +            writingStartTag = false;
  +        }
  +        
  +        getEncoder().writeEncoded(writer, string);
  +        onlyXML=false;
       }
   
       /**
  @@ -1374,5 +1374,12 @@
   
       public void setWriteXMLType(QName type) {
           writeXMLType = type;
  +    }
  +
  +    public XMLEncoder getEncoder() {
  +        if(encoder == null) {
  +            encoder = XMLUtils.getXMLEncoder(msgContext);
  +        }
  +        return encoder;
       }
   }
  
  
  
  1.8       +2 -16     ws-axis/java/src/org/apache/axis/utils/Mapping.java
  
  Index: Mapping.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/Mapping.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- Mapping.java	25 Feb 2004 14:02:48 -0000	1.7
  +++ Mapping.java	26 Apr 2004 11:51:43 -0000	1.8
  @@ -20,10 +20,7 @@
   
   public class Mapping implements Serializable {
       private String namespaceURI;
  -    private int namespaceHash;
  -
       private String prefix;
  -    private int prefixHash;
   
       public Mapping (String namespaceURI, String prefix) {
           setPrefix(prefix);
  @@ -34,26 +31,15 @@
           return namespaceURI;
       }
   
  -    public int getNamespaceHash() {
  -        return namespaceHash;
  -    }
  -
       public void setNamespaceURI (String namespaceURI) {
  -        this.namespaceURI = namespaceURI;
  -        this.namespaceHash = namespaceURI.hashCode();
  +        this.namespaceURI = namespaceURI.intern();
       }
   
       public String getPrefix() {
           return prefix;
       }
   
  -    public int getPrefixHash() {
  -        return prefixHash;
  -    }
  -
       public void setPrefix (String prefix) {
  -        this.prefix = prefix;
  -        this.prefixHash = prefix.hashCode();
  +        this.prefix = prefix.intern();
       }
  -
   }
  
  
  
  1.43      +22 -20    ws-axis/java/src/org/apache/axis/utils/NSStack.java
  
  Index: NSStack.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/NSStack.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- NSStack.java	25 Feb 2004 14:02:48 -0000	1.42
  +++ NSStack.java	26 Apr 2004 11:51:43 -0000	1.43
  @@ -163,10 +163,11 @@
        */
       public void add(String namespaceURI, String prefix) {
           int idx = top;
  +        prefix = prefix.intern();
           try {
               // Replace duplicate prefixes (last wins - this could also fault)
               for (int cursor=top; stack[cursor]!=null; cursor--) {
  -                if (stack[cursor].getPrefix().equals(prefix)) {
  +                if (stack[cursor].getPrefix() == prefix) {
                       stack[cursor].setNamespaceURI(namespaceURI);
                       idx = cursor;
                       return;
  @@ -201,36 +202,37 @@
        * find one because "pre" is actually mapped to "otherNamespace"
        */ 
       public String getPrefix(String namespaceURI, boolean noDefault) {
  -        if ((namespaceURI == null) || (namespaceURI.equals("")))
  +        if ((namespaceURI == null) || (namespaceURI.length()==0))
               return null;
           
  -        int hash = namespaceURI.hashCode();
  -
           // If defaults are OK, and the given NS is the current default,
           // return "" as the prefix to favor defaults where possible.
           if (!noDefault && currentDefaultNS > 0 && stack[currentDefaultNS] != null &&
  -                namespaceURI.equals(
  -                        stack[currentDefaultNS].getNamespaceURI()))
  +                namespaceURI == stack[currentDefaultNS].getNamespaceURI())
               return "";
               
  +        namespaceURI = namespaceURI.intern();
  +
           for (int cursor=top; cursor>0; cursor--) {
               Mapping map = stack[cursor];
  -            if (map == null) continue;
  +            if (map == null) 
  +                continue;
   
  -            if (map.getNamespaceHash() == hash &&
  -                map.getNamespaceURI().equals(namespaceURI)) {
  +            if (map.getNamespaceURI() == namespaceURI) {
                   String possiblePrefix = map.getPrefix();
  -                if (noDefault && possiblePrefix.length() == 0) continue;
  -
  +                if (noDefault && possiblePrefix.length() == 0)
  +                    continue;
  +    
                   // now make sure that this is the first occurance of this 
                   // particular prefix
  -                int ppHash = possiblePrefix.hashCode();
  -                for (int cursor2=top; true; cursor2--) {
  -                   if (cursor2 == cursor) return possiblePrefix;
  -                   map = stack[cursor2];
  -                   if (map == null) continue;
  -                   if (ppHash == map.getPrefixHash() &&
  -                       possiblePrefix.equals(map.getPrefix())) break;
  +                for (int cursor2 = top; true; cursor2--) {
  +                    if (cursor2 == cursor)
  +                        return possiblePrefix;
  +                    map = stack[cursor2];
  +                    if (map == null)
  +                        continue;
  +                    if (possiblePrefix == map.getPrefix())
  +                        break;
                   }
               }
           }
  @@ -253,13 +255,13 @@
           if (prefix == null)
               prefix = "";
   
  -        int hash = prefix.hashCode();
  +        prefix = prefix.intern();
   
           for (int cursor=top; cursor>0; cursor--) {
               Mapping map = stack[cursor];
               if (map == null) continue;
           
  -            if (map.getPrefixHash() == hash && map.getPrefix().equals(prefix))
  +            if (map.getPrefix() == prefix)
                   return map.getNamespaceURI();
           }
           
  
  
  
  1.93      +71 -46    ws-axis/java/src/org/apache/axis/utils/XMLUtils.java
  
  Index: XMLUtils.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/utils/XMLUtils.java,v
  retrieving revision 1.92
  retrieving revision 1.93
  diff -u -r1.92 -r1.93
  --- XMLUtils.java	25 Feb 2004 14:02:48 -0000	1.92
  +++ XMLUtils.java	26 Apr 2004 11:51:43 -0000	1.93
  @@ -16,38 +16,10 @@
   
   package org.apache.axis.utils ;
   
  -import java.io.ByteArrayInputStream;
  -import java.io.ByteArrayOutputStream;
  -import java.io.IOException;
  -import java.io.InputStream;
  -import java.io.OutputStream;
  -import java.io.OutputStreamWriter;
  -import java.io.StringWriter;
  -import java.io.UnsupportedEncodingException;
  -import java.io.Writer;
  -import java.net.HttpURLConnection;
  -import java.net.MalformedURLException;
  -import java.net.ProtocolException;
  -import java.net.URL;
  -import java.net.URLConnection;
  -import java.util.Iterator;
  -import java.util.List;
  -import java.util.Stack;
  -
  -import javax.xml.namespace.QName;
  -import javax.xml.parsers.DocumentBuilder;
  -import javax.xml.parsers.DocumentBuilderFactory;
  -import javax.xml.parsers.ParserConfigurationException;
  -import javax.xml.parsers.SAXParser;
  -import javax.xml.parsers.SAXParserFactory;
  -import javax.xml.transform.Source;
  -import javax.xml.transform.dom.DOMSource;
  -import javax.xml.transform.sax.SAXSource;
  -import javax.xml.transform.stream.StreamSource;
  -
   import org.apache.axis.AxisEngine;
   import org.apache.axis.Constants;
   import org.apache.axis.InternalException;
  +import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.components.encoding.XMLEncoder;
   import org.apache.axis.components.encoding.XMLEncoderFactory;
  @@ -67,6 +39,36 @@
   import org.xml.sax.SAXParseException;
   import org.xml.sax.XMLReader;
   
  +import javax.xml.namespace.QName;
  +import javax.xml.parsers.DocumentBuilder;
  +import javax.xml.parsers.DocumentBuilderFactory;
  +import javax.xml.parsers.ParserConfigurationException;
  +import javax.xml.parsers.SAXParser;
  +import javax.xml.parsers.SAXParserFactory;
  +import javax.xml.soap.SOAPException;
  +import javax.xml.soap.SOAPMessage;
  +import javax.xml.transform.Source;
  +import javax.xml.transform.dom.DOMSource;
  +import javax.xml.transform.sax.SAXSource;
  +import javax.xml.transform.stream.StreamSource;
  +import java.io.ByteArrayInputStream;
  +import java.io.ByteArrayOutputStream;
  +import java.io.IOException;
  +import java.io.InputStream;
  +import java.io.OutputStream;
  +import java.io.OutputStreamWriter;
  +import java.io.StringWriter;
  +import java.io.UnsupportedEncodingException;
  +import java.io.Writer;
  +import java.net.HttpURLConnection;
  +import java.net.MalformedURLException;
  +import java.net.ProtocolException;
  +import java.net.URL;
  +import java.net.URLConnection;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Stack;
  +
   
   public class XMLUtils {
       protected static Log log =
  @@ -95,7 +97,7 @@
        */
       public static String xmlEncodeString(String orig)
       {
  -        XMLEncoder encoder = getXMLEncoder();
  +        XMLEncoder encoder = getXMLEncoder(MessageContext.getCurrentContext());
           return encoder.encode(orig);
       }
   
  @@ -103,23 +105,14 @@
        * Get the current XMLEncoder
        * @return XMLEncoder
        */ 
  -    private static XMLEncoder getXMLEncoder() {
  -        MessageContext msgContext = MessageContext.getCurrentContext();
  +    public static XMLEncoder getXMLEncoder(MessageContext msgContext) {
           XMLEncoder encoder = null;
  -        if(msgContext == null) {
  +        String encoding = getEncoding(null, msgContext);
  +        try {
  +            encoder = XMLEncoderFactory.getEncoder(encoding);
  +        } catch (Exception e) {
  +            log.error(Messages.getMessage("exception00"), e);
               encoder = XMLEncoderFactory.getDefaultEncoder();
  -        } else {
  -            String encoding = (String) msgContext.getAxisEngine().getOption(AxisEngine.PROP_XML_ENCODING);
  -            try {
  -                if(encoding != null) {
  -                    encoder = XMLEncoderFactory.getEncoder(encoding);
  -                } else {
  -                    encoder = XMLEncoderFactory.getDefaultEncoder();
  -                }
  -            } catch (Exception e) {
  -                log.error(Messages.getMessage("exception00"), e);
  -                encoder = XMLEncoderFactory.getDefaultEncoder();
  -            }
           }
           return encoder;
       }
  @@ -128,8 +121,17 @@
        * Get the current encoding in effect
        * @return string 
        */ 
  +    public static String getEncoding(MessageContext msgContext) {
  +        XMLEncoder encoder = getXMLEncoder(msgContext);
  +        return encoder.getEncoding();        
  +    }
  +
  +    /**
  +     * Get the current encoding in effect
  +     * @return string 
  +     */ 
       public static String getEncoding() {
  -        XMLEncoder encoder = getXMLEncoder();
  +        XMLEncoder encoder = getXMLEncoder(MessageContext.getCurrentContext());
           return encoder.getEncoding();        
       }
   
  @@ -837,5 +839,28 @@
           }
           
           return elements;
  +    }
  +
  +    public static String getEncoding(Message message, MessageContext msgContext){
  +        String encoding = null;
  +        try {
  +            if(message != null) {
  +                encoding = (String) message.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  +            }
  +        } catch (SOAPException e) {
  +        }
  +        if(msgContext == null) {
  +            msgContext = MessageContext.getCurrentContext();  
  +        } 
  +        if(msgContext != null && encoding == null){
  +            encoding = (String) msgContext.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  +        }
  +        if (msgContext != null && encoding == null) {
  +            encoding = (String) msgContext.getAxisEngine().getOption(AxisEngine.PROP_XML_ENCODING);
  +        }
  +        if (encoding == null) {
  +            encoding = XMLEncoderFactory.getDefaultEncoder().getEncoding();
  +        }
  +        return encoding;
       }
   }
  
  
  
  1.1                  ws-axis/java/src/org/apache/axis/utils/ByteArray.java
  
  Index: ByteArray.java
  ===================================================================
  /*
   * Copyright 2001-2004 The Apache Software Foundation.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.apache.axis.utils;
  
  import java.io.BufferedInputStream;
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileNotFoundException;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.OutputStream;
  
  /**
   * Class ByteArray
   */
  public class ByteArray extends OutputStream {
  
      protected byte cache[] = null;
      protected int cache_fp = 0;
      protected double cache_increment = 1.3;
      protected int max_size = 0;
      protected File bs_handle = null;
      protected OutputStream bs_stream = null;
      protected long count = 0;
  
      /**
       * Constructor ByteArray
       */
      public ByteArray() {
          this(16 * 512);
      }
  
      /**
       * Constructor ByteArray
       * 
       * @param max_resident_size 
       */
      public ByteArray(int max_resident_size) {
          this(0, max_resident_size);
      }
  
      /**
       * Constructor ByteArray
       * 
       * @param probable_size     
       * @param max_resident_size 
       */
      public ByteArray(int probable_size, int max_resident_size) {
          if (probable_size > max_resident_size) {
              probable_size = 0;
          }
          if (probable_size < 1024) {
              probable_size = 1024;
          }
          cache = new byte[probable_size];
          max_size = max_resident_size;
      }
  
      /**
       * Method write
       * 
       * @param bytes 
       * @throws IOException 
       */
      public void write(byte bytes[]) throws IOException {
          count += bytes.length;
          write(bytes, 0, bytes.length);
      }
  
      /**
       * Method write
       * 
       * @param bytes  
       * @param start  
       * @param length 
       * @throws IOException 
       */
      public void write(byte bytes[], int start, int length) throws IOException {
          count += length;
          if (cache != null) {
              increaseCapacity(length);
          }
          if (cache != null) {
              System.arraycopy(bytes, start, cache, cache_fp, length);
              cache_fp += length;
          } else {
              bs_stream.write(bytes, start, length);
          }
      }
  
      /**
       * Method write
       * 
       * @param b 
       * @throws IOException 
       */
      public void write(int b) throws IOException {
          count += 1;
          if (cache != null) {
              increaseCapacity(1);
          }
          if (cache != null) {
              cache[cache_fp++] = (byte) b;
          } else {
              bs_stream.write(b);
          }
      }
  
      /**
       * Method close
       * 
       * @throws IOException 
       */
      public void close() throws IOException {
          if (bs_stream != null) {
              bs_stream.close();
              bs_stream = null;
          }
      }
  
      /**
       * Method size
       * 
       * @return 
       */
      public long size() {
          return count;
      }
  
      /**
       * Method flush
       * 
       * @throws IOException 
       */
      public void flush() throws IOException {
          if (bs_stream != null) {
              bs_stream.flush();
          }
      }
  
      /**
       * Method increaseCapacity
       * 
       * @param count 
       * @throws IOException 
       */
      protected void increaseCapacity(int count) throws IOException {
          if (cache == null) {
              return;
          }
          int new_fp = cache_fp + count;
          if (new_fp < cache.length) {
              return;
          }
          if (new_fp < max_size) {
              grow(count);
          } else {
              switchToBackingStore();
          }
      }
  
      /**
       * Method growMemCache
       * 
       * @param count 
       * @throws IOException 
       */
      protected void grow(int count) throws IOException {
          int new_fp = cache_fp + count;
          int new_size = (int) (cache.length * cache_increment);
          if (new_size < cache_fp + 1024) {
              new_size = cache_fp + 1024;
          }
          if (new_size < new_fp) {
              new_size = new_fp;
          }
          try {
              byte new_mem_cache[] = new byte[new_size];
              System.arraycopy(cache, 0, new_mem_cache, 0, cache_fp);
              cache = new_mem_cache;
          } catch (OutOfMemoryError e) {
              // Couldn't allocate a new, bigger vector!
              // That's fine, we'll just switch to backing-store mode.
              switchToBackingStore();
          }
      }
  
      /**
       * Method discardBuffer
       */
      public synchronized void discardBuffer() {
          cache = null;
          cache_fp = 0;
          if (bs_stream != null) {
              try {
                  bs_stream.close();
              } catch (IOException e) {
                  // just ignore it...
              }
              bs_stream = null;
          }
          discardBackingStore();
      }
  
      /**
       * Method makeInputStream
       * 
       * @return 
       * @throws IOException           
       * @throws FileNotFoundException 
       */
      protected InputStream makeInputStream()
              throws IOException, FileNotFoundException {
          close();
          if (cache != null) {
              byte[] v = cache;
              int fp = cache_fp;
              cache = null;
              cache_fp = 0;
              return new ByteArrayInputStream(v, 0, fp);
          } else if (bs_handle != null) {
              return createBackingStoreInputStream();
          } else {
              return null;
          }
      }
  
      /**
       * Method finalize
       */
      protected void finalize() {
          discardBuffer();
      }
  
      /**
       * Method switchToBackingStore
       * 
       * @throws IOException 
       */
      protected void switchToBackingStore() throws IOException {
          bs_handle = File.createTempFile("Axis", ".msg");
          bs_handle.createNewFile();
          bs_handle.deleteOnExit();
          bs_stream = new FileOutputStream(bs_handle);
          if (cache_fp > 0) {
              bs_stream.write(cache, 0, cache_fp);
          }
          cache = null;
          cache_fp = 0;
      }
  
      /**
       * Method discardBackingStore
       */
      protected void discardBackingStore() {
          if (bs_handle != null) {
              bs_handle.delete();
              bs_handle = null;
          }
      }
  
      /**
       * Method createBackingStoreInputStream
       * 
       * @return 
       * @throws FileNotFoundException 
       */
      protected InputStream createBackingStoreInputStream()
              throws FileNotFoundException {
          try {
              return new BufferedInputStream(
                      new FileInputStream(bs_handle.getCanonicalPath()));
          } catch (IOException e) {
              throw new FileNotFoundException(bs_handle.getAbsolutePath());
          }
      }
  
      /**
       * Method toByteArray
       * 
       * @return 
       * @throws IOException 
       */
      public byte[] toByteArray() throws IOException {
          InputStream inp = this.makeInputStream();
          byte[] buf = null;
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          buf = new byte[4096];
          int len;
          while ((len = inp.read(buf, 0, 4096)) != -1) {
              baos.write(buf, 0, len);
          }
          inp.close();
          discardBackingStore();
          return baos.toByteArray();
      }
  
      /**
       * Method writeTo
       * 
       * @param os 
       * @throws IOException 
       */
      public void writeTo(OutputStream os) throws IOException {
          InputStream inp = this.makeInputStream();
          byte[] buf = null;
          buf = new byte[4096];
          int len;
          while ((len = inp.read(buf, 0, 4096)) != -1) {
              os.write(buf, 0, len);
          }
          inp.close();
          discardBackingStore();
      }
  }
  
  
  
  1.31      +1 -0      ws-axis/java/test/encoding/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/encoding/PackageTests.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- PackageTests.java	8 Dec 2003 16:03:06 -0000	1.30
  +++ PackageTests.java	26 Apr 2004 11:51:43 -0000	1.31
  @@ -26,6 +26,7 @@
           suite.addTestSuite(TestDeser2001.class);
           suite.addTestSuite(TestSer.class);
           suite.addTestSuite(TestString.class);
  +        suite.addTestSuite(TestString2.class);
           suite.addTestSuite(TestHrefs.class);
           suite.addTestSuite(TestBody.class);
           suite.addTestSuite(TestDOM.class);
  
  
  
  1.15      +1 -109    ws-axis/java/test/encoding/TestString.java
  
  Index: TestString.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/encoding/TestString.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- TestString.java	26 Nov 2003 10:44:08 -0000	1.14
  +++ TestString.java	26 Apr 2004 11:51:43 -0000	1.15
  @@ -1,109 +1 @@
  -package test.encoding;
  -
  -import junit.framework.TestCase;
  -import org.apache.axis.MessageContext;
  -import org.apache.axis.encoding.DeserializationContext;
  -import org.apache.axis.encoding.DeserializationContextImpl;
  -import org.apache.axis.encoding.SerializationContext;
  -import org.apache.axis.encoding.SerializationContextImpl;
  -import org.apache.axis.message.RPCElement;
  -import org.apache.axis.message.RPCParam;
  -import org.apache.axis.message.SOAPEnvelope;
  -import org.apache.axis.server.AxisServer;
  -import org.xml.sax.InputSource;
  -
  -import java.io.StringReader;
  -import java.io.StringWriter;
  -import java.io.Writer;
  -import java.io.ByteArrayOutputStream;
  -import java.io.OutputStreamWriter;
  -import java.io.ByteArrayInputStream;
  -
  -/** Little serialization test with a struct.
  - */
  -public class TestString extends TestCase {
  -
  -    public static final String myNS = "urn:myNS";
  -    
  -    public TestString(String name) {
  -        super(name);
  -    }
  -
  -    private void runtest(String value, String expected) throws Exception {
  -        MessageContext msgContext = new MessageContext(new AxisServer());
  -        SOAPEnvelope msg = new SOAPEnvelope();
  -        RPCParam input = new RPCParam("urn:myNamespace", "testParam", value);
  -        
  -        RPCElement body = new RPCElement("urn:myNamespace", "method1", new Object[]{ input });
  -        msg.addBodyElement(body);
  -        
  -        ByteArrayOutputStream baos = new ByteArrayOutputStream();
  -        OutputStreamWriter writer = new OutputStreamWriter(baos,"UTF-8");
  -        SerializationContext context = new SerializationContextImpl(writer, msgContext);
  -        msg.output(context);
  -        writer.flush();
  -        
  -        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
  -        DeserializationContext dser = new DeserializationContextImpl(
  -            new InputSource(bais), msgContext, org.apache.axis.Message.REQUEST);
  -        dser.parse();
  -        
  -        SOAPEnvelope env = dser.getEnvelope();
  -        RPCElement rpcElem = (RPCElement)env.getFirstBody();
  -        RPCParam output = rpcElem.getParam("testParam");
  -        assertNotNull("No <testParam> param", output);
  -        
  -        String result = (String)output.getValue();
  -        assertNotNull("No value for testParam param", result);
  -        
  -        assertEquals("Expected result not received.", expected, result);
  -    }
  -
  -    private void runtest(String value) throws Exception {
  -        runtest(value, value);
  -    }
  -
  -    public void testSimpleString() throws Exception {
  -        runtest("a simple string");
  -    }
  -
  -    public void testStringWithApostrophes() throws Exception {
  -        runtest("this isn't a simple string");
  -    }
  -
  -    public void testStringWithEntities() throws Exception {
  -        runtest("&amp;&lt;&gt;&apos;&quot;", "&amp;&lt;&gt;&apos;&quot;");
  -    }
  -    
  -    public void testStringWithRawEntities() throws Exception {
  -        runtest("&<>'\"", "&<>'\"");
  -    }
  -    
  -    public void testStringWithLeadingAndTrailingSpaces() throws Exception {
  -        runtest("          centered          ");
  -    }
  -    
  -    public void testWhitespace() throws Exception {
  -        runtest(" \n \t "); // note: \r fails
  -    }
  -
  -    public void testFrenchAccents() throws Exception {
  -        runtest("\u00e0\u00e2\u00e4\u00e7\u00e8\u00e9\u00ea\u00eb\u00ee\u00ef\u00f4\u00f6\u00f9\u00fb\u00fc");
  -    }
  -    
  -    public void testFrenchAccents2() throws Exception {
  -        runtest("Une chaîne avec des caractères accentués");
  -    }
  -    
  -    public void testGermanUmlauts() throws Exception {
  -        runtest(" Some text \u00df with \u00fc special \u00f6 chars \u00e4.");
  -    }
  -    
  -    public void testWelcomeUnicode() throws Exception {
  -        // welcome in several languages
  -        runtest(
  -          "Chinese (trad.) : \u6b61\u8fce  \n" +
  -          "Greek : \u03ba\u03b1\u03bb\u03ce\u03c2 \u03bf\u03c1\u03af\u03c3\u03b1\u03c4\u03b5 \n"+
  -          "Japanese : \u3088\u3046\u3053\u305d");
  -    }
  -}
  +package test.encoding;

import junit.framework.TestCase;
import org.apache.axis.MessageContext;
import org.apache.axis.encoding.DeserializationContext;
import org.apache.axis.encoding.DeserializationContextImpl;
import org.apache.axis.encoding.SerializationContext;
import org.apache.axis.encoding.SerializationContextImpl;
import org.apache.axis.message.RPCElement;
import org.apache.axis.message.RPCParam;
import org.apache.axis.message.SOAPEnvelope;
import org.apache.axis.server.AxisServer;
import org.xml.sax.InputSource;

import javax.xml.soap.MessageFactory;
import javax.xml.soap.SOAPMessage;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.ByteArrayInputStream;

/** Little serialization test with a struct.
 */
public class TestString extends TestCase {

    public static final String myNS = "urn:myNS";
    
    public TestString(String name) {
        super(name);
    }

    private void runtest(String value, String expected) throws Exception {
        MessageContext msgContext = new MessageContext(new AxisServer());
        MessageFactory factory = MessageFactory.newInstance();
        org.apache.axis.Message message = (org.apache.axis.Message) factory.createMessage();
        message.setMessageContext(msgContext);
        String requestEncoding = "UTF-8";
        msgContext.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, requestEncoding);
        message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, requestEncoding);
        RPCParam input = new RPCParam("urn:myNamespace", "testParam", value);
        
        RPCElement body = new RPCElement("urn:myNamespace", "method1", new Object[]{ input });
        message.getSOAPBody().addChildElement(body);
        
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        message.writeTo(baos);
        
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        DeserializationContext dser = new DeserializationContextImpl(
            new InputSource(bais), msgContext, org.apache.axis.Message.REQUEST);
        dser.parse();
        
        org.apache.axis.message.SOAPEnvelope env = dser.getEnvelope();
        RPCElement rpcElem = (RPCElement)env.getFirstBody();
        RPCParam output = rpcElem.getParam("testParam");
        assertNotNull("No <testParam> param", output);
        
        String result = (String)output.getValue();
        assertNotNull("No value for testParam param", result);
        
        assertEquals("Expected result not received.", expected, result);
    }

    private void runtest(String value) throws Exception {
        runtest(value, value);
    }

    public void testSimpleString() throws Exception {
        runtest("a simple string");
    }

    public void testStringWithApostrophes() throws Exception {
        runtest("this isn't a simple string");
    }

    public void testStringWithEntities() throws Exception {
        runtest("&amp;&lt;&gt;&apos;&quot;", "&amp;&lt;&gt;&apos;&quot;");
    }
    
    public void testStringWithRawEntities() throws Exception {
        runtest("&<>'\"", "&<>'\"");
    }
    
    public void testStringWithLeadingAndTrailingSpaces() throws Exception {
        runtest("          centered          ");
    }
    
    public void testWhitespace() throws Exception {
        runtest(" \n \t "); // note: \r fails
    }

    public void testFrenchAccents() throws Exception {
        runtest("\u00e0\u00e2\u00e4\u00e7\u00e8\u00e9\u00ea\u00eb\u00ee\u00ef\u00f4\u00f6\u00f9\u00fb\u00fc");
    }
    
    public void testFrenchAccents2() throws Exception {
        runtest("Une chaîne avec des caractères accentués");
    }
    
    public void testGermanUmlauts() throws Exception {
        runtest(" Some text \u00df with \u00fc special \u00f6 chars \u00e4.");
    }
    
    public void testWelcomeUnicode() throws Exception {
        // welcome in several languages
        runtest(
          "Chinese (trad.) : \u6b61\u8fce  ");
    }

    public void testWelcomeUnicode2() throws Exception {
        // welcome in several languages
        runtest(
          "Greek : \u03ba\u03b1\u03bb\u03ce\u03c2 \u03bf\u03c1\u03af\u03c3\u03b1\u03c4\u03b5");
    }

    public void testWelcomeUnicode3() throws Exception {
        // welcome in several languages
        runtest(
          "Japanese : \u3088\u3046\u3053\u305d");
    }
}
  \ No newline at end of file
  
  
  
  1.1                  ws-axis/java/test/encoding/TestString2.java
  
  Index: TestString2.java
  ===================================================================
  package test.encoding;
  
  import junit.framework.TestCase;
  import org.apache.axis.MessageContext;
  import org.apache.axis.encoding.DeserializationContext;
  import org.apache.axis.encoding.DeserializationContextImpl;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.SerializationContextImpl;
  import org.apache.axis.message.RPCElement;
  import org.apache.axis.message.RPCParam;
  import org.apache.axis.server.AxisServer;
  import org.xml.sax.InputSource;
  
  import javax.xml.soap.SOAPMessage;
  import javax.xml.soap.MessageFactory;
  import javax.xml.soap.SOAPEnvelope;
  import java.io.StringReader;
  import java.io.StringWriter;
  import java.io.Writer;
  import java.io.ByteArrayOutputStream;
  import java.io.OutputStreamWriter;
  import java.io.ByteArrayInputStream;
  
  /** Little serialization test with a struct.
   */
  public class TestString2 extends TestCase {
  
      public static final String myNS = "urn:myNS";
      
      public TestString2(String name) {
          super(name);
      }
  
      private void runtest(String value, String expected) throws Exception {
          MessageContext msgContext = new MessageContext(new AxisServer());
          MessageFactory factory = MessageFactory.newInstance();
          org.apache.axis.Message message = (org.apache.axis.Message) factory.createMessage();
          message.setMessageContext(msgContext);
          String requestEncoding = "UTF-16";
          msgContext.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, requestEncoding);
          message.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, requestEncoding);
          RPCParam input = new RPCParam("urn:myNamespace", "testParam", value);
          
          RPCElement body = new RPCElement("urn:myNamespace", "method1", new Object[]{ input });
          message.getSOAPBody().addChildElement(body);
          
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          message.writeTo(baos);
          
          ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
          DeserializationContext dser = new DeserializationContextImpl(
              new InputSource(bais), msgContext, org.apache.axis.Message.REQUEST);
          dser.parse();
          
          org.apache.axis.message.SOAPEnvelope env = dser.getEnvelope();
          RPCElement rpcElem = (RPCElement)env.getFirstBody();
          RPCParam output = rpcElem.getParam("testParam");
          assertNotNull("No <testParam> param", output);
          
          String result = (String)output.getValue();
          assertNotNull("No value for testParam param", result);
          
          assertEquals("Expected result not received.", expected, result);
      }
  
      private void runtest(String value) throws Exception {
          runtest(value, value);
      }
  
      public void testSimpleString() throws Exception {
          runtest("a simple string");
      }
  
      public void testStringWithApostrophes() throws Exception {
          runtest("this isn't a simple string");
      }
  
      public void testStringWithEntities() throws Exception {
          runtest("&amp;&lt;&gt;&apos;&quot;", "&amp;&lt;&gt;&apos;&quot;");
      }
      
      public void testStringWithRawEntities() throws Exception {
          runtest("&<>'\"", "&<>'\"");
      }
      
      public void testStringWithLeadingAndTrailingSpaces() throws Exception {
          runtest("          centered          ");
      }
      
      public void testWhitespace() throws Exception {
          runtest(" \n \t "); // note: \r fails
      }
  
      public void testFrenchAccents() throws Exception {
          runtest("\u00e0\u00e2\u00e4\u00e7\u00e8\u00e9\u00ea\u00eb\u00ee\u00ef\u00f4\u00f6\u00f9\u00fb\u00fc");
      }
      
      public void testFrenchAccents2() throws Exception {
          runtest("Une chaîne avec des caractères accentués");
      }
      
      public void testGermanUmlauts() throws Exception {
          runtest(" Some text \u00df with \u00fc special \u00f6 chars \u00e4.");
      }
      
      public void testWelcomeUnicode() throws Exception {
          // welcome in several languages
          runtest(
            "Chinese (trad.) : \u6b61\u8fce  ");
      }
  
      public void testWelcomeUnicode2() throws Exception {
          // welcome in several languages
          runtest(
            "Greek : \u03ba\u03b1\u03bb\u03ce\u03c2 \u03bf\u03c1\u03af\u03c3\u03b1\u03c4\u03b5");
      }
  
      public void testWelcomeUnicode3() throws Exception {
          // welcome in several languages
          runtest(
            "Japanese : \u3088\u3046\u3053\u305d");
      }
  }
  
  
  
  1.5       +1 -1      ws-axis/java/test/functional/TestEncoding.java
  
  Index: TestEncoding.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/test/functional/TestEncoding.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestEncoding.java	5 Mar 2004 10:33:36 -0000	1.4
  +++ TestEncoding.java	26 Apr 2004 11:51:44 -0000	1.5
  @@ -112,6 +112,6 @@
           URLEndpoint endpoint = new URLEndpoint("http://localhost:8080/jws/EchoHeaders.jws");
           SOAPMessage response = con.call(message, endpoint);
           String responseEncoding = (String) response.getProperty(SOAPMessage.CHARACTER_SET_ENCODING);
  -        assertEquals(requestEncoding, responseEncoding);
  +        assertEquals(requestEncoding.toLowerCase(), responseEncoding.toLowerCase());
       }
   }
  
  
  

Mime
View raw message