You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2004/06/17 23:48:39 UTC

cvs commit: ws-axis/java/src/org/apache/axis/utils XMLUtils.java

dims        2004/06/17 14:48:39

  Modified:    java/src/org/apache/axis/client Call.java
               java/src/org/apache/axis SOAPPart.java
               java/src/org/apache/axis/utils XMLUtils.java
  Log:
  fixes for tck failures:
  - if a message is already in a stream, leave it alone.
  - if a utf-16 message is already in a stream, dont treat it as utf-8
  
  Revision  Changes    Path
  1.225     +14 -8     ws-axis/java/src/org/apache/axis/client/Call.java
  
  Index: Call.java
  ===================================================================
  RCS file: /home/cvs/ws-axis/java/src/org/apache/axis/client/Call.java,v
  retrieving revision 1.224
  retrieving revision 1.225
  diff -u -r1.224 -r1.225
  --- Call.java	17 May 2004 16:24:50 -0000	1.224
  +++ Call.java	17 Jun 2004 21:48:39 -0000	1.225
  @@ -24,6 +24,7 @@
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.AxisEngine;
  +import org.apache.axis.SOAPPart;
   import org.apache.axis.attachments.Attachments;
   import org.apache.axis.components.logger.LogFactory;
   import org.apache.axis.description.FaultDesc;
  @@ -2629,8 +2630,10 @@
               } else {
                   // No direct config, so try the namespace of the first body.
                   reqMsg = msgContext.getRequestMessage();
  -
  -                if (reqMsg != null) {
  +                
  +                boolean isStream = ((SOAPPart)reqMsg.getSOAPPart()).isBodyStream();
  +                
  +                if (reqMsg != null && !isStream) {
                       reqEnv = reqMsg.getSOAPEnvelope();
   
                       SOAPBodyElement body = reqEnv.getFirstBody();
  @@ -2658,11 +2661,14 @@
                   msgContext.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, requestMessage.getProperty(SOAPMessage.CHARACTER_SET_ENCODING));
               } catch (SOAPException e) {
               }
  -            reqEnv = requestMessage.getSOAPEnvelope();
  -
  -            // If we have headers to insert, do so now.
  -            for (int i = 0 ; myHeaders != null && i < myHeaders.size() ; i++ ) {
  -                reqEnv.addHeader((SOAPHeaderElement)myHeaders.get(i));
  +            
  +            if(myHeaders != null) {
  +                reqEnv = requestMessage.getSOAPEnvelope();
  +    
  +                // If we have headers to insert, do so now.
  +                for (int i = 0 ; myHeaders != null && i < myHeaders.size() ; i++ ) {
  +                    reqEnv.addHeader((SOAPHeaderElement)myHeaders.get(i));
  +                }
               }
           }
   
  @@ -2687,7 +2693,7 @@
               try {
                   SerializationContext ctx = new SerializationContextImpl(writer,
                                                                      msgContext);
  -                reqEnv.output(ctx);
  +                requestMessage.getSOAPEnvelope().output(ctx);
                   writer.close();
               } catch (Exception e) {
                   log.debug(Messages.getMessage("exceptionPrinting"), e);
  
  
  
  1.70      +10 -1     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.69
  retrieving revision 1.70
  diff -u -r1.69 -r1.70
  --- SOAPPart.java	14 Jun 2004 15:47:21 -0000	1.69
  +++ SOAPPart.java	17 Jun 2004 21:48:39 -0000	1.70
  @@ -355,6 +355,11 @@
             currentMessageAsEnvelope= (org.apache.axis.message.SOAPEnvelope )currMsg;
       }
   
  +    
  +    public int getCurrentForm() {
  +        return currentForm;
  +    }
  +    
       /**
        * Get the contents of this Part (not the headers!), as a byte
        * array.  This will force buffering of the message.
  @@ -623,7 +628,7 @@
   
           if ( currentForm == FORM_INPUTSTREAM ) {
               is = new InputSource( (InputStream) currentMessage );
  -            String encoding = XMLUtils.getEncoding(msgObject, null);
  +            String encoding = XMLUtils.getEncoding(msgObject, null, null);
               if (encoding != null) {
                   is.setEncoding(encoding);
               }
  @@ -1209,6 +1214,10 @@
   
       public boolean hasAttributes(){
           return document.hasAttributes();
  +    }
  +    
  +    public boolean isBodyStream() {
  +        return (currentForm == SOAPPart.FORM_INPUTSTREAM || currentForm == SOAPPart.FORM_BODYINSTREAM);        
       }
   }
   
  
  
  
  1.94      +11 -3     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.93
  retrieving revision 1.94
  diff -u -r1.93 -r1.94
  --- XMLUtils.java	26 Apr 2004 11:51:43 -0000	1.93
  +++ XMLUtils.java	17 Jun 2004 21:48:39 -0000	1.94
  @@ -841,7 +841,15 @@
           return elements;
       }
   
  -    public static String getEncoding(Message message, MessageContext msgContext){
  +    public static String getEncoding(Message message,
  +                                     MessageContext msgContext) {
  +        return getEncoding(message, msgContext,
  +                XMLEncoderFactory.getDefaultEncoder());
  +    }
  +
  +    public static String getEncoding(Message message,
  +                                     MessageContext msgContext,
  +                                     XMLEncoder defaultEncoder) {
           String encoding = null;
           try {
               if(message != null) {
  @@ -858,8 +866,8 @@
           if (msgContext != null && encoding == null) {
               encoding = (String) msgContext.getAxisEngine().getOption(AxisEngine.PROP_XML_ENCODING);
           }
  -        if (encoding == null) {
  -            encoding = XMLEncoderFactory.getDefaultEncoder().getEncoding();
  +        if (encoding == null && defaultEncoder != null) {
  +            encoding = defaultEncoder.getEncoding();
           }
           return encoding;
       }