AXISCPP-1070 - Add support for element that references a schema
diff --git a/src/soap/SoapDeSerializer.cpp b/src/soap/SoapDeSerializer.cpp
index 3c23d6b..f2de8b7 100644
--- a/src/soap/SoapDeSerializer.cpp
+++ b/src/soap/SoapDeSerializer.cpp
@@ -2216,7 +2216,15 @@
     bool bElementFound = false;
 
     AxisString xmlStr = "";
+
+    // There may have been namespace declarations that were previously processed....get it from
+    // the node and reset the node variable.
     AxisString nsDecls = "";
+    if (m_pNode)
+    {
+        nsDecls = ((AnyElement*)m_pNode)->m_strXMLNSDeclsForAnyObject.c_str();
+        ((AnyElement*)m_pNode)->m_strXMLNSDeclsForAnyObject.clear();
+    }
 
     stack <AxisString> nsPrefixStack;
 
@@ -2235,6 +2243,9 @@
         {
             if (0 != strcmp (pName, m_pNode->m_pchNameOrValue))
             {
+                // Need to save namespace string just in case it is needed later.
+                ((AnyElement*)m_pNode)->m_strXMLNSDeclsForAnyObject = nsDecls.c_str();
+
                 logExitWithPointer(NULL)
 
                 return (AnyType *)NULL;
diff --git a/src/xml/AnyElement.h b/src/xml/AnyElement.h
index 8b6535f..2a29fc8 100644
--- a/src/xml/AnyElement.h
+++ b/src/xml/AnyElement.h
@@ -50,8 +50,16 @@
  * @enum XML_NODE_TYPE
  * Enumeration that defines the SAX events that the AnyElement may contain
  */
-typedef enum { START_ELEMENT=0, CHARACTER_ELEMENT, END_ELEMENT, 
-    START_PREFIX, END_PREFIX, START_END_ELEMENT, UNKNOWN} XML_NODE_TYPE;
+typedef enum
+{
+    START_ELEMENT=0,
+    CHARACTER_ELEMENT,
+    END_ELEMENT,
+    START_PREFIX,
+    END_PREFIX,
+    START_END_ELEMENT,
+    UNKNOWN
+} XML_NODE_TYPE;
 
 /**
  * @struct AnyElement
@@ -97,6 +105,14 @@
      * NULL it is understood as the end of attributes.
      */
     const char* m_pchAttributes[MAX_NO_OF_ATTRIBUTES*3]; 
+
+    /**
+     * This is the namespace declarations for an element that has yet been processed but for which
+     * the namespace declarations have been consumed (which is the reason for this variable). See
+     * SoapDeserializer::getAnyObject().
+     */
+    std::string m_strXMLNSDeclsForAnyObject;
+
 } AnyElement;
 
 /*
@@ -133,4 +149,3 @@
 };
 
 #endif
-
diff --git a/src/xml/xerces/XercesHandler.cpp b/src/xml/xerces/XercesHandler.cpp
index 36a987e..2bc6ca7 100644
--- a/src/xml/xerces/XercesHandler.cpp
+++ b/src/xml/xerces/XercesHandler.cpp
@@ -235,6 +235,8 @@
         }
         else
         {
+            m_pCurrElement->m_strXMLNSDeclsForAnyObject.clear();
+
             // free all inner strings
             if (m_pCurrElement->m_pchNameOrValue)
             {