axis-c-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nadira...@apache.org
Subject svn commit: r940943 - in /axis/axis1/c/trunk/src: soap/SoapDeSerializer.cpp soap/SoapDeSerializer.h wsdl/org/apache/axis/wsdl/symbolTable/CSchemaUtils.java wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java
Date Tue, 04 May 2010 16:41:21 GMT
Author: nadiramra
Date: Tue May  4 16:41:21 2010
New Revision: 940943

URL: http://svn.apache.org/viewvc?rev=940943&view=rev
Log:
AXISCPP-1070 - Add support for element that references a schema

Modified:
    axis/axis1/c/trunk/src/soap/SoapDeSerializer.cpp
    axis/axis1/c/trunk/src/soap/SoapDeSerializer.h
    axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/symbolTable/CSchemaUtils.java
    axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java
    axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java

Modified: axis/axis1/c/trunk/src/soap/SoapDeSerializer.cpp
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/soap/SoapDeSerializer.cpp?rev=940943&r1=940942&r2=940943&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/soap/SoapDeSerializer.cpp (original)
+++ axis/axis1/c/trunk/src/soap/SoapDeSerializer.cpp Tue May  4 16:41:21 2010
@@ -1930,13 +1930,7 @@ getElementAsAnyType(const AxisChar* pNam
     if (AXIS_SUCCESS != m_nStatus)
         return ret;
         
-    if (AXIS_FAIL == getNextNode(RPC_ENCODED != m_nStyle))
-        return ret;
-
-    if (RPC_ENCODED != m_nStyle && (0 != strcmp (pName, m_pNode->m_pchNameOrValue)))
-       return ret;
-    
-    AnyType *any = getAnyObject();
+    AnyType *any = getAnyObject(pName, pNamespace);
     if (NULL != any)
     {
         if (any->_size != 0)
@@ -2182,125 +2176,154 @@ flushInputStream ()
 AnyType * SoapDeSerializer::
 getAnyObject ()
 {
+    return getAnyObject(NULL, NULL);
+}
+
+
+AnyType * SoapDeSerializer::
+getAnyObject (const AxisChar* pName, const AxisChar* pNamespace)
+{
     logEntryEngine("SoapDeSerializer::getAnyObject")
 
+    // If pname is passed, then we need to move the parser pointer for RPC.
+    if (pName != NULL && RPC_ENCODED == m_nStyle)
+    {
+        m_pNode = m_pParser->anyNext();
+        if (m_pNode == NULL)
+        {
+            logExitWithPointer(NULL)
+
+            return (AnyType *)NULL;
+        }
+    }
+
     // Parser will throw an exception on a parser exception, that is ok...
     if (!m_pNode)
+    {
         m_pNode = m_pParser->anyNext();
-    
-    AnyType *pAny = NULL;
-    
-    if (m_pNode)
-    {    
-        int tagCount = 0;
-        int lstSize = 0;
-        bool bContinue = false;
-    
-        AxisString xmlStr = "";
-        AxisString nsDecls = "";
-    
-        list < AxisString > lstXML;
-    
-        AxisString inValue = "";
-        AxisString outValue = "";
-    
-        while ((END_ELEMENT != m_pNode->m_type) || (tagCount >= 0) || bContinue)
-        {
-            // Continue if processing start prefix,
-            // as we haven't yet found the true start of the tag
-            if (START_PREFIX == m_pNode->m_type)
-                bContinue = true;
-            else
-                bContinue = false;
-            
-            // if empty element we need to do a parser get to consume the end-element node.
-            if (START_END_ELEMENT == m_pNode->m_type2)
-            {
-                if (END_ELEMENT == m_pNode->m_type)
-                    m_pNode = m_pParser->anyNext ();
-            }
-            else
-            {
-                // Increment counter if entering new tag, Decrement counter if exiting tag
-                if (START_ELEMENT == m_pNode->m_type)
-                    tagCount++;
-                else if (END_ELEMENT == m_pNode->m_type)
-                    tagCount--;
-            }
 
-            if (START_PREFIX == m_pNode->m_type)
-            {
-                nsDecls += " xmlns";
-                if (m_pNode->m_pchNameOrValue && (*(m_pNode->m_pchNameOrValue)
!= 0x00))
-                {
-                    nsDecls += ":";
-                    nsDecls += m_pNode->m_pchNameOrValue;
-                }
-                nsDecls += "=";
-                nsDecls += PLATFORM_DOUBLE_QUOTE_S;
-                nsDecls += m_pNode->m_pchNamespace;
-                nsDecls += PLATFORM_DOUBLE_QUOTE_S;
-            }
-            else if (CHARACTER_ELEMENT != m_pNode->m_type)
-            {
-                serializeTag (xmlStr, m_pNode, nsDecls);
-                nsDecls = "";
-            }
-            else
+        if (m_pNode == NULL)
+        {
+            logExitWithPointer(NULL)
+
+            return (AnyType *)NULL;
+        }
+    }
+
+    int tagCount = 0;
+    int lstSize = 0;
+    bool bContinue = true;
+    bool bElementFound = false;
+
+    AxisString xmlStr = "";
+    AxisString nsDecls = "";
+
+    stack <AxisString> nsPrefixStack;
+
+    AxisString inValue = "";
+    AxisString outValue = "";
+
+    // Loop and get an XML element node and its sub-elements.
+    // Note the a schema element will not be counted as an element but will be included as
part
+    // of the data returned.
+    while (m_pNode && ((END_ELEMENT != m_pNode->m_type) || (tagCount > 0) ||
bContinue))
+    {
+        // Root element needs to be what is expected for doc/literal.
+        if (pName != NULL
+                && RPC_ENCODED != m_nStyle
+                && START_ELEMENT == m_pNode->m_type)
+        {
+            if (0 != strcmp (pName, m_pNode->m_pchNameOrValue))
             {
-                inValue = m_pNode->m_pchNameOrValue;
-                IAnySimpleType::replaceReservedCharacters(inValue, outValue);
-                xmlStr += outValue;
+                logExitWithPointer(NULL)
+
+                return (AnyType *)NULL;
             }
-        
-            /* copy the First level element into the list */
-            if ( !bContinue && tagCount == 0 && (!xmlStr.empty ()))
-            {
-                lstXML.push_back (xmlStr);
-                xmlStr = "";
 
-                // If the anyType element is empty element, we need to consume END_ELEMENT.
-                if (START_END_ELEMENT == m_pNode->m_type2 && START_ELEMENT ==
m_pNode->m_type)
-                    m_pNode = m_pParser->anyNext ();
+            // We do not need to do the check anymore
+            pName = NULL;
+        }
 
-                m_pNode = NULL;
-                break;
-            }
-        
-            m_pNode = m_pParser->anyNext ();
-        
-            if (!m_pNode) // there is something wrong in the XSD Any XML stream
-            {          
-                // Store whatever we have by now and break
-                if (!xmlStr.empty ())
-                {
-                    lstXML.push_back (xmlStr);
-                    xmlStr = "";
-                }
-                break;
+        // Continue if processing start prefix as we haven't yet found the true start of
the tag
+        bContinue = false;
+        if (START_PREFIX == m_pNode->m_type)
+            bContinue = true;
+
+        // if empty element we need to do a parser get to consume the end-element node.
+        // Note that start/end elements are not included in tagCount processing since the
node
+        // is processed completely on first pass since it contains no sub-elements.
+        if (START_END_ELEMENT == m_pNode->m_type2)
+        {
+            if (END_ELEMENT == m_pNode->m_type)
+            {
+                m_pNode = m_pParser->anyNext ();
+                continue;
             }
         }
-    
-        pAny = new AnyType ();
-        pAny->_array = 0;
-        pAny->_size = 0;
-        
-        lstSize = lstXML.size ();
-        
-        if (lstSize > 0)
+        else
         {
-            pAny->_array = new char *[lstSize];
-    
-            list < AxisString >::iterator i;    /* Iterator for traversing the list
*/
-        
-            for (i = lstXML.begin (); i != lstXML.end (); i++)
+            // Increment counter if entering new tag, Decrement counter if exiting tag
+            if (START_ELEMENT == m_pNode->m_type)
+                tagCount++;
+            else if (END_ELEMENT == m_pNode->m_type)
+                tagCount--;
+        }
+
+        if (START_PREFIX == m_pNode->m_type)
+        {
+            nsDecls += " xmlns";
+            if (m_pNode->m_pchNameOrValue && (*(m_pNode->m_pchNameOrValue)
!= 0x00))
             {
-                const char *s = (*i).c_str ();
-                pAny->_array[pAny->_size] = new char[strlen (s) + 1];
-                strcpy (pAny->_array[pAny->_size], s);
-                pAny->_size++;
+                nsDecls += ":";
+                nsDecls += m_pNode->m_pchNameOrValue;
             }
+            nsDecls += "=";
+            nsDecls += PLATFORM_DOUBLE_QUOTE_S;
+            nsDecls += m_pNode->m_pchNamespace;
+            nsDecls += PLATFORM_DOUBLE_QUOTE_S;
+        }
+        else if (CHARACTER_ELEMENT != m_pNode->m_type)
+        {
+            bElementFound = true;
+            serializeTag (xmlStr, m_pNode, nsDecls, nsPrefixStack);
+            nsDecls = "";
+        }
+        else
+        {
+            inValue = m_pNode->m_pchNameOrValue;
+            IAnySimpleType::replaceReservedCharacters(inValue, outValue);
+            xmlStr += outValue;
+        }
+
+        // If element obtained...break out. Otherwise, get next node.
+        if (bElementFound && !bContinue && tagCount == 0 && (!xmlStr.empty
()))
+        {
+            // If the anyType element is empty element, we need to consume END_ELEMENT.
+            if (START_END_ELEMENT == m_pNode->m_type2 && START_ELEMENT == m_pNode->m_type)
+                m_pNode = m_pParser->anyNext ();
+
+            m_pNode = NULL;
         }
+        else
+            m_pNode = m_pParser->anyNext ();
+    }
+
+    // Generate the axis type where we store anyType XML objects.
+    AnyType *pAny = new AnyType ();
+    pAny->_array = 0;
+    pAny->_size = 0;
+
+    if (!xmlStr.empty ())
+    {
+        pAny->_array = new char *[1];
+
+        const char *s = xmlStr.c_str ();
+        logDebugArg1("\nAnyType array element\n%s\n", s)
+
+        pAny->_array[0] = new char[xmlStr.size() + 1];
+        strcpy (pAny->_array[0], s);
+
+        pAny->_size  = 1;
     }
 
     logExitWithPointer(pAny)
@@ -2308,31 +2331,36 @@ getAnyObject ()
     return pAny;
 }
 
-
 void SoapDeSerializer::
 serializeTag (AxisString & xmlStr, 
               const AnyElement * node,
-              AxisString & nsDecls)
+              AxisString & nsDecls,
+              std::stack<AxisString> & nsPrefixStack)
 {
-    /*
-       Note that if this is an end tag and since m_pchNameOrValue doesn't give
-       the "/" sign. So we have to add that sign as well in to the end tag
-     */
     const XML_Ch *pchPrefix = 0;
 
+    AxisString nsPrefix = "";
+
     if (START_ELEMENT == node->m_type)
     {
         xmlStr += "<";
+
         if (node->m_pchNamespace && (*(node->m_pchNamespace) != 0x00))
         {
             pchPrefix = m_pParser->getPrefix4NS (node->m_pchNamespace);
 
             if (pchPrefix && *pchPrefix != 0x00)
             {
+                nsPrefix = pchPrefix;
+
                 xmlStr += pchPrefix;
                 xmlStr += ":";
             }
         }
+
+        // We do not need to save namespace prefix if start/end element.
+        if (START_END_ELEMENT != node->m_type2)
+            nsPrefixStack.push(nsPrefix);
     
         xmlStr += node->m_pchNameOrValue;
 
@@ -2376,7 +2404,7 @@ serializeTag (AxisString & xmlStr, 
         }
 
         if (START_END_ELEMENT == node->m_type2)
-            xmlStr += "/>";
+            xmlStr += " />";
         else
             xmlStr += ">";
     }
@@ -2384,49 +2412,23 @@ serializeTag (AxisString & xmlStr, 
     {
         AxisString prefixTag = "";
 
-        if (node->m_pchNamespace && (*(node->m_pchNamespace) != 0x00))
+        if (!nsPrefixStack.empty())
         {
-            pchPrefix = m_pParser->getPrefix4NS (node->m_pchNamespace);
+            nsPrefix = nsPrefixStack.top();
+            nsPrefixStack.pop();
 
-            if (pchPrefix && (*pchPrefix != 0x00))
+            if (!nsPrefix.empty())
             {
-                prefixTag += pchPrefix;
+                prefixTag += nsPrefix;
                 prefixTag += ":";
             }
-            else
-            {
-                // This code is required because the namespace for the closing tag may have
-                // been deleted before it can be checked (m_pParser->getPrefix4NS).  If
it has
-                // been deleted, then the code needs to look at the opening tag and use that
-                // namespace prefix for the closing tag.
-                // This is because:-
-                // [2511] m_pNode = m_pParser->anyNext() calls
-                //   XercesHandler::endPrefixMapping() and this deletes the namespace before
it
-                // can be looked up by m_pParser->getPrefix4NS!
-
-                string elementWithColon = ":";
-                elementWithColon += node->m_pchNameOrValue;
-
-                string::size_type nsEnd    = xmlStr.rfind(elementWithColon);
-                string::size_type tagStart = xmlStr.find_last_of('<');
-                string::size_type tagEnd   = xmlStr.find_last_of('>');
-
-                if (nsEnd != std::string::npos
-                       && tagStart != std::string::npos
-                       && tagEnd != std::string::npos
-                       && (nsEnd > tagStart)
-                       && (nsEnd < tagEnd))
-                {
-                    prefixTag = xmlStr.substr( tagStart + 1, nsEnd - tagStart);
-                }
-            }
         }
 
         xmlStr += "</";
         xmlStr += prefixTag;
         xmlStr += node->m_pchNameOrValue;
         if (START_END_ELEMENT == node->m_type2)
-            xmlStr += "/>";
+            xmlStr += " />";
         else
             xmlStr += ">";
     }

Modified: axis/axis1/c/trunk/src/soap/SoapDeSerializer.h
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/soap/SoapDeSerializer.h?rev=940943&r1=940942&r2=940943&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/soap/SoapDeSerializer.h (original)
+++ axis/axis1/c/trunk/src/soap/SoapDeSerializer.h Tue May  4 16:41:21 2010
@@ -18,6 +18,8 @@
 #if !defined(_SOAPDESERIALIZER_H____OF_AXIS_INCLUDED_)
 #define _SOAPDESERIALIZER_H____OF_AXIS_INCLUDED_
 
+#include <stack>
+
 #include <axis/IHandlerSoapDeSerializer.hpp>
 #include "HeaderBlock.h"
 #include "../xml/XMLParser.h"
@@ -305,7 +307,7 @@ public:
     AXIS_BINDING_STYLE getStyle(){return m_nStyle;};    
     int AXISCALL getStatus(){return m_nStatus;};
     AnyType* AXISCALL getAnyObject();
-    void serializeTag(AxisString& xmlStr, const AnyElement* node, AxisString& nsDecls);
+    void serializeTag(AxisString& xmlStr, const AnyElement* node, AxisString& nsDecls,
std::stack<AxisString> & nsPrefixStack);
     void getChardataAs(void** pValue, XSDTYPE type);
 
     /**
@@ -346,6 +348,7 @@ private:
     int skipNode(bool verifyIfEndNode=false, bool throwExcOnError=true);
     int getNextNode(bool ifNotSet=false, bool characterMode=false, bool throwExcOnError=true);

     void throwParserException();
+    AnyType * getAnyObject (const AxisChar* pName, const AxisChar* pNamespace);
 };
 
 AXIS_CPP_NAMESPACE_END

Modified: axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/symbolTable/CSchemaUtils.java
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/symbolTable/CSchemaUtils.java?rev=940943&r1=940942&r2=940943&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/symbolTable/CSchemaUtils.java (original)
+++ axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/symbolTable/CSchemaUtils.java Tue May
 4 16:41:21 2010
@@ -786,9 +786,18 @@ public class CSchemaUtils extends Schema
 
         // The type qname is used to locate the TypeEntry, which is then
         // used to retrieve the proper java name of the type.
-        QName nodeType = Utils.getTypeQName(elementNode, forElement, false);
+        QName nodeType = Utils.getTypeQName(elementNode, forElement, false);        
         TypeEntry type = symbolTable.getTypeEntry(nodeType, forElement.value);
         
+        // We want to treat schema references same way we treat anyType. 
+        if (type == null 
+                && nodeType.getLocalPart().equals("schema") 
+                && nodeType.getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema"))
+        {
+            forElement.value = false;
+            type = symbolTable.getTypeEntry(nodeType, forElement.value);
+        }
+        
         //The boolean field 'qualified' is set to true 
         //if the element is namespace qualified.
         //The default value is unqualified.

Modified: axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java?rev=940943&r1=940942&r2=940943&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java (original)
+++ axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/CUtils.java Tue May  4 16:41:21
2010
@@ -52,6 +52,7 @@ public class CUtils 
     public static final String CLASS_LOADER_APPENDER = "Service";
     public static final QName xsdAnyElementQName = new QName("http://ws.apache.org/axisc/types","AnyType");
     public static final QName xsdAnyTypeQName = new QName(WrapperConstants.SCHEMA_NAMESPACE,"anyType");
+    public static final QName xsdSchemaQName  = new QName(WrapperConstants.SCHEMA_NAMESPACE,"schema");
 
     // File suffix for C++ Class files
     private static final String CPP_CLASS_SUFFIX = ".cpp";
@@ -221,6 +222,8 @@ public class CUtils 
         c_qnameToPrimitiveTypeMapperCPP.put(new QName(WrapperConstants.SCHEMA_NAMESPACE,
"NOTATION"),                "xsd__NOTATION");
         c_qnameToPrimitiveTypeMapperCPP.put(new QName(WrapperConstants.SCHEMA_NAMESPACE,
"anyType"),                "xsd__anyType");
         
+        c_qnameToPrimitiveTypeMapperCPP.put(new QName(WrapperConstants.SCHEMA_NAMESPACE,
"schema"),                 "xsd__anyType");
+        
         // TODO revisit attachment support.
         c_qnameToPrimitiveTypeMapperCPP.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE,
"Image"),       "ISoapAttachment");
         c_qnameToPrimitiveTypeMapperCPP.put(new QName(WrapperConstants.APACHE_XMLSOAP_NAMESPACE,
"PlainText"),  "ISoapAttachment");
@@ -276,6 +279,8 @@ public class CUtils 
         c_qnameToPrimitiveTypeMapperC.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "anyURI"),
               "xsdc__anyURI");
         c_qnameToPrimitiveTypeMapperC.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "NOTATION"),
           "xsdc__NOTATION");
         c_qnameToPrimitiveTypeMapperC.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "anyType"),
               "xsdc__anyType");
+        c_qnameToPrimitiveTypeMapperC.put(new QName(WrapperConstants.SCHEMA_NAMESPACE, "schema"),
                "xsdc__anyType");
+
 
         /* TODO:
          *   Should be removed when the following issue will be fixed :
@@ -840,6 +845,17 @@ public class CUtils 
     }
     
     /**
+     * Method to determine if QName represents a schema.
+     * 
+     * @param name
+     * @return
+     */
+    public static boolean isSchemaReference(QName name)
+    {
+            return name.equals(xsdSchemaQName);
+    }
+    
+    /**
      * Method to determine if QName represents an xsd:anyType.
      * 
      * @param name
@@ -847,7 +863,8 @@ public class CUtils 
      */
     public static boolean isAnyType(QName name)
     {
-            return name.equals(xsdAnyTypeQName);
+        // Note we treat schema reference as xsd:anyType.
+            return (name.equals(xsdAnyTypeQName) || isSchemaReference(name));
     }
     
     /**

Modified: axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java
URL: http://svn.apache.org/viewvc/axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java?rev=940943&r1=940942&r2=940943&view=diff
==============================================================================
--- axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java (original)
+++ axis/axis1/c/trunk/src/wsdl/org/apache/axis/wsdl/wsdl2ws/info/Type.java Tue May  4 16:41:21
2010
@@ -117,6 +117,8 @@ public class Type
     // is any element?  This is true for xsd:any.
     private boolean c_isAnyElement = false;
 
+    // is schema reference? This is true for something like <element ref="s:schema">
+    private boolean c_isSchemaReference = false;
 
     /**
      * Constructor.
@@ -160,8 +162,9 @@ public class Type
         }
         
         // See if this type represents an xsd:any element or an xsd:anyType type.
-        c_isAnyType    = CUtils.isAnyType(name);
-        c_isAnyElement = CUtils.isAnyElement(name);
+        c_isAnyType         = CUtils.isAnyType(name);
+        c_isAnyElement      = CUtils.isAnyElement(name);
+        c_isSchemaReference = CUtils.isSchemaReference(name);
 
         if (name.getNamespaceURI().equals(WrapperConstants.APACHE_XMLSOAP_NAMESPACE) &&

             (name.getLocalPart().equals("DataHandler") ||
@@ -550,6 +553,14 @@ public class Type
     }
 
     /**
+     * @return the c_isSchemaReference
+     */
+    public boolean isSchemaRefernce()
+    {
+        return c_isSchemaReference;
+    }
+    
+    /**
      * @return the c_isAnyType
      */
     public boolean isAnyType()



Mime
View raw message