axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdani...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/soap MessageFactoryImpl.java
Date Tue, 20 May 2003 15:07:01 GMT
gdaniels    2003/05/20 08:07:01

  Modified:    java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis/message MessageElement.java
                        SOAPBody.java SOAPEnvelope.java
               java/src/org/apache/axis/soap MessageFactoryImpl.java
  Log:
  Fix three SAAJ compatibility errors.
  
  * Don't initialize SOAPBody with a prefix, to avoid an extraneous
    namespace mapping.
  
  * Don't complain when adding non-SOAPBodyElement children to
    SOAPBody - SAAJ expects (and the TCK tests) that you can do this
    with a MessageElement.
  
  * When initializing a SOAPEnvelope from the SAAJ MessageFactory,
    set a "SAAJ encoding compatibility" flag, which will cause us to check
    the value of any encodingStyle we set on the Body, and ensure it matches
    a known value.  This is a bit of a specific fix (i.e. it causes the TCK to pass
    but only makes the check in a very specific case) because I think it's
    broken - you should be able to create ANY SOAP message with the
    SAAJ APIs, even ones with encodingStyles you don't directly support.
  
  With these changes we *should* now be able to pass the SAAJ TCK.
  
  Revision  Changes    Path
  1.55      +1 -0      xml-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- resource.properties	22 Apr 2003 17:39:59 -0000	1.54
  +++ resource.properties	20 May 2003 15:07:01 -0000	1.55
  @@ -1136,6 +1136,7 @@
   errorGetDocFromSOAPEnvelope=Could not get document from SOAPEnvelope
   badEjbHomeType=The home object retrieved from jndi does not have the same type as the one
specified in the config file
   badEncodingStyle=Unknown encoding style
  +badEncodingStyle1=Unknown encoding style : {0}
   
   badSOAPHeader00=a SOAPHeader may only have SOAPHeaderElement as its immediate children
   badSOAPBodyElement00=a SOAPBody may only have SOAPBodyElement as its immediate children
  
  
  
  1.153     +1 -5      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.152
  retrieving revision 1.153
  diff -u -r1.152 -r1.153
  --- MessageElement.java	7 May 2003 13:49:24 -0000	1.152
  +++ MessageElement.java	20 May 2003 15:07:01 -0000	1.153
  @@ -60,11 +60,7 @@
   import org.apache.axis.AxisFault;
   import org.apache.axis.enum.Style;
   import org.apache.axis.components.logger.LogFactory;
  -import org.apache.axis.encoding.DeserializationContext;
  -import org.apache.axis.encoding.DeserializationContextImpl;
  -import org.apache.axis.encoding.Deserializer;
  -import org.apache.axis.encoding.SerializationContext;
  -import org.apache.axis.encoding.SerializationContextImpl;
  +import org.apache.axis.encoding.*;
   import org.apache.axis.soap.SOAPConstants;
   import org.apache.axis.utils.Mapping;
   import org.apache.axis.utils.Messages;
  
  
  
  1.43      +32 -6     xml-axis/java/src/org/apache/axis/message/SOAPBody.java
  
  Index: SOAPBody.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPBody.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- SOAPBody.java	22 Apr 2003 19:35:16 -0000	1.42
  +++ SOAPBody.java	20 May 2003 15:07:01 -0000	1.43
  @@ -72,6 +72,7 @@
   import javax.xml.soap.SOAPException;
   import java.util.Enumeration;
   import java.util.Vector;
  +import java.util.ArrayList;
   
   /**
    * Holder for body elements.
  @@ -88,11 +89,17 @@
       private SOAPConstants soapConstants;
   
       private boolean disableFormatting = false;
  +    private boolean doSAAJEncodingCompliance = false;
  +    private static ArrayList knownEncodingStyles = new ArrayList();
  +    static {
  +        knownEncodingStyles.add(Constants.URI_SOAP11_ENC);
  +        knownEncodingStyles.add(Constants.URI_SOAP12_ENC);
  +        knownEncodingStyles.add("");
  +        knownEncodingStyles.add(Constants.URI_SOAP12_NOENC);
  +    }
   
       SOAPBody(SOAPEnvelope env, SOAPConstants soapConsts) {
  -       super(Constants.ELEM_BODY,
  -             Constants.NS_PREFIX_SOAP_ENV,
  -             soapConsts.getEnvelopeURI());
  +       super(soapConsts.getEnvelopeURI(), Constants.ELEM_BODY);
          soapConstants = soapConsts;
           try {
               setParentElement(env);
  @@ -129,6 +136,20 @@
           this.disableFormatting = true;
       }
   
  +    public void setEncodingStyle(String encodingStyle) throws SOAPException {
  +        if (encodingStyle == null) {
  +            encodingStyle = "";
  +        }
  +
  +        if (doSAAJEncodingCompliance) {
  +            // Make sure this matches a known encodingStyle.  This is
  +            if (!knownEncodingStyles.contains(encodingStyle))
  +                throw new IllegalArgumentException(Messages.getMessage("badEncodingStyle1",
encodingStyle));
  +        }
  +
  +        super.setEncodingStyle(encodingStyle);
  +    }
  +
       protected void outputImpl(SerializationContext context) throws Exception {
           boolean oldPretty = context.getPretty();
           if (!disableFormatting) {
  @@ -306,9 +327,14 @@
        */ 
       public SOAPElement addChildElement(SOAPElement element) 
         throws SOAPException {
  -      if (!(element instanceof javax.xml.soap.SOAPBodyElement)) {
  -        throw new SOAPException(Messages.getMessage("badSOAPBodyElement00"));
  -      } 
  +// Commented out for SAAJ compatibility - gdaniels, 05/19/2003
  +//      if (!(element instanceof javax.xml.soap.SOAPBodyElement)) {
  +//        throw new SOAPException(Messages.getMessage("badSOAPBodyElement00"));
  +//      }
         return super.addChildElement(element);
  +    }
  +
  +    public void setSAAJEncodingCompliance(boolean comply) {
  +        this.doSAAJEncodingCompliance = true;
       }
   }
  
  
  
  1.90      +4 -0      xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java
  
  Index: SOAPEnvelope.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPEnvelope.java,v
  retrieving revision 1.89
  retrieving revision 1.90
  diff -u -r1.89 -r1.90
  --- SOAPEnvelope.java	27 Apr 2003 01:21:35 -0000	1.89
  +++ SOAPEnvelope.java	20 May 2003 15:07:01 -0000	1.90
  @@ -626,4 +626,8 @@
       public javax.xml.soap.SOAPHeader getHeader() throws SOAPException {
           return header;
       }
  +
  +    public void setSAAJEncodingCompliance(boolean comply) {
  +        this.body.setSAAJEncodingCompliance(comply);
  +    }
   }
  
  
  
  1.8       +3 -1      xml-axis/java/src/org/apache/axis/soap/MessageFactoryImpl.java
  
  Index: MessageFactoryImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/soap/MessageFactoryImpl.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MessageFactoryImpl.java	22 Apr 2003 19:35:46 -0000	1.7
  +++ MessageFactoryImpl.java	20 May 2003 15:07:01 -0000	1.8
  @@ -88,7 +88,9 @@
        * @throws  SOAPException if a SOAP error occurs
        */
       public SOAPMessage createMessage() throws SOAPException {
  -        Message message = new Message(new SOAPEnvelope());
  +        SOAPEnvelope env = new SOAPEnvelope();
  +        env.setSAAJEncodingCompliance(true);
  +        Message message = new Message(env);
           message.setMessageType(Message.REQUEST);
           return message;
       }
  
  
  

Mime
View raw message