You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by gd...@apache.org on 2001/05/10 17:50:29 UTC

cvs commit: xml-axis/java/src/org/apache/axis/message MessageElement.java SOAPSAXHandler.java

gdaniels    01/05/10 08:50:28

  Modified:    java/src/org/apache/axis/message MessageElement.java
                        SOAPSAXHandler.java
  Log:
  Couple of quick changes to better support cases where we're doing
  messaging-style processing (and hence not deserializing).  These make
  sure that all SAX events get recorded and played back correctly in the
  case where we have a ServiceDescription that has "isRPC" set to false.
  
  Again, I expect this architecture will be refactored somewhat over the next
  few weeks to be cleaner and more based around the concept of "Service",
  so a lot of these little strangenesses should go away.
  
  Revision  Changes    Path
  1.19      +58 -43    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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- MessageElement.java	2001/05/09 23:14:45	1.18
  +++ MessageElement.java	2001/05/10 15:50:21	1.19
  @@ -88,7 +88,7 @@
       
       protected ElementRecorder recorder = null;
       protected DeserializerBase deserializer = null;
  -    protected boolean deserializing = true;
  +    protected Boolean deserializing = null;
   
       /** No-arg constructor for building messages?
        */
  @@ -130,6 +130,19 @@
         }
       }
       
  +    public boolean isDeserializing()
  +    {
  +        boolean deser;
  +        if (deserializing == null) {
  +            ServiceDescription s = context.getServiceDescription();
  +            deser = ((s == null) || (s.isRPC()));
  +            deserializing = new Boolean(deser);
  +        } else {
  +            deser = deserializing.booleanValue();
  +        }
  +        return deser;
  +    }
  +    
       public boolean getRoot() { return isRoot; }
       public String getID() { return id; }
       
  @@ -189,55 +202,57 @@
           if (DEBUG_LOG) {
               System.err.println("Start element in MessageElement.");
           }
  -        
  -        if (typeQName == null)
  -            typeQName = context.getTypeFromAttributes(attributes);
  -
  -        // !!! This check might not be complete; in the case of
  -        //     a multi-ref, we might need to check BOTH the name
  -        //     of the element with the href AND the referenced
  -        //     one.  Right now this will just check the referenced one.
  -        if (typeQName == null) {
  -            QName myQName = new QName(namespace, localName);
  -            if (myQName.equals(SOAPTypeMappingRegistry.SOAP_ARRAY)) {
  -                typeQName = SOAPTypeMappingRegistry.SOAP_ARRAY;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_INT)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_INT;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_BOOLEAN)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_BOOLEAN;
  -            } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_SHORT)) {
  -                typeQName = SOAPTypeMappingRegistry.XSD_SHORT;
  +    
  +        if (isDeserializing()) {
  +            if (typeQName == null)
  +                typeQName = context.getTypeFromAttributes(attributes);
  +
  +            // !!! This check might not be complete; in the case of
  +            //     a multi-ref, we might need to check BOTH the name
  +            //     of the element with the href AND the referenced
  +            //     one.  Right now this will just check the referenced one.
  +            if (typeQName == null) {
  +                QName myQName = new QName(namespace, localName);
  +                if (myQName.equals(SOAPTypeMappingRegistry.SOAP_ARRAY)) {
  +                    typeQName = SOAPTypeMappingRegistry.SOAP_ARRAY;
  +                } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_INT)) {
  +                    typeQName = SOAPTypeMappingRegistry.XSD_INT;
  +                } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_BOOLEAN)) {
  +                    typeQName = SOAPTypeMappingRegistry.XSD_BOOLEAN;
  +                } else if (myQName.equals(SOAPTypeMappingRegistry.SOAP_SHORT)) {
  +                    typeQName = SOAPTypeMappingRegistry.XSD_SHORT;
  +                }
               }
  -        }
  -        
  -        if (typeQName == null) {
  -            // No type inline, so check service description.
  -            ServiceDescription serviceDesc = context.getServiceDescription();
  -            if (serviceDesc != null) {
  -                SOAPEnvelope env = getEnvelope();
  -                if ( env != null )
  -                  setType(serviceDesc.getParamTypeByName(env.getMessageType(),
  -                                                             name));
  +            
  +            if (typeQName == null) {
  +                // No type inline, so check service description.
  +                ServiceDescription serviceDesc = context.getServiceDescription();
  +                if (serviceDesc != null) {
  +                    SOAPEnvelope env = getEnvelope();
  +                    if (env != null)
  +                        setType(serviceDesc.getParamTypeByName(
  +                                                 env.getMessageType(), name));
  +                }
               }
  +
  +            /** !!! If we have a service description and this is an
  +            * explicitly-typed param, we might want to check here to
  +            * see if the xsi:type val is indeed a subtype of the type
  +            * we expect from the service description.
  +            */
  +
  +            DeserializerBase dSer = getContentHandler();
  +            
  +            context.getSAXHandler().replaceElementHandler(dSer);
  +            
  +            if (dSer != this)
  +                dSer.startElement(namespace,localName,qName,attributes);
           }
  -        
  -        /** !!! If we have a service description and this is an
  -        * explicitly-typed param, we might want to check here to
  -        * see if the xsi:type val is indeed a subtype of the type
  -        * we expect from the service description.
  -        */
  -        
  -        DeserializerBase dSer = getContentHandler();
  -        
  -        context.getSAXHandler().replaceElementHandler(dSer);
  -        
  -        if (dSer != this)
  -            dSer.startElement(namespace,localName,qName,attributes);
       }
    
       public DeserializerBase getContentHandler()
       {
  -        if (deserializing) {
  +        if (isDeserializing()) {
               // Look up type and return an appropriate deserializer
               if ((typeQName != null) && (deserializer == null)) {
                   deserializer = context.getDeserializer(typeQName);
  
  
  
  1.12      +3 -0      xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java
  
  Index: SOAPSAXHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPSAXHandler.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SOAPSAXHandler.java	2001/05/07 19:56:34	1.11
  +++ SOAPSAXHandler.java	2001/05/10 15:50:22	1.12
  @@ -403,6 +403,9 @@
       public boolean needsStartElement(Attributes attributes)
           throws SAXException
       {
  +        if (elementHandler instanceof ElementRecorder)
  +            return true;
  +        
           String href = attributes.getValue(Constants.ATTR_HREF);
           if (href != null) {
               if (DEBUG_LOG) {