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/07/09 16:15:28 UTC

cvs commit: xml-axis/java/src/org/apache/axis/transport/http HTTPSender.java

gdaniels    01/07/09 07:15:28

  Modified:    java/src/org/apache/axis AxisFault.java
               java/src/org/apache/axis/encoding
                        DeserializationContext.java
               java/src/org/apache/axis/message MessageElement.java
                        RPCElement.java SOAPFaultElement.java
               java/src/org/apache/axis/transport/http HTTPSender.java
  Log:
  Slight alteration to deserialization system - we now attempt to figure out
  the type of a MessageElement at construction time, which fixes a
  multi-ref bug.
  
  Also add a constructor for building MessageElements with just namespace/
  localName.
  
  Revision  Changes    Path
  1.22      +1 -2      xml-axis/java/src/org/apache/axis/AxisFault.java
  
  Index: AxisFault.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/AxisFault.java,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- AxisFault.java	2001/06/21 11:15:14	1.21
  +++ AxisFault.java	2001/07/09 14:15:12	1.22
  @@ -173,8 +173,7 @@
       SOAPEnvelope envelope = new SOAPEnvelope();
   
       SOAPFaultElement fault = 
  -      new SOAPFaultElement(Constants.URI_SOAP_ENV, "Fault", null, null);
  -    fault.setAxisFault(this);
  +      new SOAPFaultElement(this);
       envelope.addBodyElement(fault);
   
       envelope.output(context);
  
  
  
  1.12      +3 -0      xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java
  
  Index: DeserializationContext.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializationContext.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- DeserializationContext.java	2001/07/08 14:18:37	1.11
  +++ DeserializationContext.java	2001/07/09 14:15:16	1.12
  @@ -120,6 +120,9 @@
       
       public QName getTypeFromAttributes(Attributes attrs)
       {
  +        if (attrs == null)
  +            return null;
  +        
           // Check for type
           String type = null;
           for (int i=0; i<Constants.URIS_SCHEMA_XSI.length && type==null; i++)
  
  
  
  1.25      +42 -69    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.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- MessageElement.java	2001/07/08 14:18:38	1.24
  +++ MessageElement.java	2001/07/09 14:15:19	1.25
  @@ -99,6 +99,12 @@
       {
       }
       
  +    MessageElement(String namespace, String localPart)
  +    {
  +        namespaceURI = namespace;
  +        name = localPart;
  +    }
  +    
       MessageElement(String namespace, String localPart,
                       Attributes attributes, DeserializationContext context)
       {
  @@ -131,6 +137,39 @@
               
           href = attributes.getValue(Constants.ATTR_HREF);
         }
  +
  +      if (typeQName == null) {
  +          QName myQName = new QName(namespaceURI, name);
  +          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));
  +          }
  +      }
  +      
  +      // Look up type and set up an appropriate deserializer
  +      if ((typeQName != null) && isDeserializing()) {
  +          deserializer = context.getDeserializer(typeQName);
  +          if (DEBUG_LOG) {
  +              System.err.println(typeQName + " maps to " + deserializer);
  +          }
  +      }
  +
       }
       
       public boolean isDeserializing()
  @@ -185,8 +224,9 @@
   
       public Object getValue()
       {
  -        if (value != null)
  +        if (value != null) {
               return value;
  +        }
           
           if (href != null) {
               return getRealElement().getValue();
  @@ -219,6 +259,7 @@
         }
         
         DeserializerBase dser = realEl.context.getDeserializer(typeQName);
  +      System.out.println(this + " got dser " + dser);
         if (dser == null)
           throw new AxisFault("No deserializer for type " + typeQName);
         
  @@ -231,83 +272,15 @@
         return dser.getValue();
       }
       
  -    public void startElement(String namespace, String localName,
  -                             String qName, Attributes attributes)
  -        throws SAXException
  -    {
  -        if (DEBUG_LOG) {
  -            System.err.println("Start element in MessageElement.");
  -        }
  - 
  -        if (isDeserializing()) {
  -            // We may have determined the default type from metadata and/or
  -            // reflection for most messages of this type, but let the XML
  -            // itself determine the xsi:type for THIS message.
  -            QName typeQNameFromAttr = context.getTypeFromAttributes(attributes);
  -            if (typeQNameFromAttr != null) typeQName = typeQNameFromAttr;
  -
  -            // !!! 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 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 (isDeserializing()) {
  -          
             if (href != null) {
               deserializer = context.getElementByID(href.substring(1));
               System.out.println("Got href dser " + deserializer);
               if (deserializer != null)
                 return deserializer;
             }
  -          
  -            // Look up type and return an appropriate deserializer
  -            if ((typeQName != null) && (deserializer == null)) {
  -                deserializer = context.getDeserializer(typeQName);
  -                if (DEBUG_LOG) {
  -                    System.err.println(typeQName + " maps to " + deserializer);
  -                }
  -            }
  -
               if (deserializer != null) {
                   return deserializer;
               }
  
  
  
  1.13      +1 -1      xml-axis/java/src/org/apache/axis/message/RPCElement.java
  
  Index: RPCElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCElement.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RPCElement.java	2001/06/21 14:27:18	1.12
  +++ RPCElement.java	2001/07/09 14:15:21	1.13
  @@ -180,7 +180,7 @@
    
           params.addElement(param);
           
  -        context.pushElementHandler(param);
  +        context.pushElementHandler(param.getContentHandler());
       }
   
       public void output(SerializationContext context)
  
  
  
  1.6       +3 -3      xml-axis/java/src/org/apache/axis/message/SOAPFaultElement.java
  
  Index: SOAPFaultElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFaultElement.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SOAPFaultElement.java	2001/06/21 11:39:57	1.5
  +++ SOAPFaultElement.java	2001/07/09 14:15:22	1.6
  @@ -155,7 +155,7 @@
   
           if (fault.getFaultCode() != null) {
             MessageElement element = new 
  -            MessageElement(Constants.URI_SOAP_ENV, "faultcode", null, null);
  +            MessageElement(Constants.URI_SOAP_ENV, "faultcode");
             QFault code = fault.getFaultCode();
             String prefix = context.getPrefixForURI(code.getNamespaceURI());
             element.setValue(prefix + ":" + code.getLocalPart());
  @@ -164,14 +164,14 @@
       
           if (fault.getFaultString() != null) {
             MessageElement element = new 
  -            MessageElement(Constants.URI_SOAP_ENV, "faultstring", null, null);
  +            MessageElement(Constants.URI_SOAP_ENV, "faultstring");
             element.setValue(fault.getFaultString());
             element.output(context);
           }
       
           if (fault.getFaultActor() != null) {
             MessageElement element = new 
  -            MessageElement(Constants.URI_SOAP_ENV, "faultactor", null, null);
  +            MessageElement(Constants.URI_SOAP_ENV, "faultactor");
             element.setValue(fault.getFaultActor());
             element.output(context);
           }
  
  
  
  1.5       +2 -0      xml-axis/java/src/org/apache/axis/transport/http/HTTPSender.java
  
  Index: HTTPSender.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/transport/http/HTTPSender.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- HTTPSender.java	2001/07/09 11:49:26	1.4
  +++ HTTPSender.java	2001/07/09 14:15:26	1.5
  @@ -96,9 +96,11 @@
         // default SOAPAction to request namespaceURI/method
         String   action = msgContext.getStrProp(HTTPConstants.MC_HTTP_SOAPACTION);
         if (action == null) {
  +          /*
           Message rm = msgContext.getRequestMessage();
           MessageElement body = rm.getAsSOAPEnvelope().getFirstBody();
           action = body.getNamespaceURI() + "/" + body.getName();
  +          */
         }
           
         host = tmpURL.getHost();