Fix namespace in SOAP fault child elements.
[shibboleth/xmltooling.git] / xmltooling / soap / impl / SOAPImpl.cpp
index be75300..62315ca 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2006 Internet2
+ *  Copyright 2001-2007 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,8 +22,8 @@
 
 #include "internal.h"
 #include "AbstractAttributeExtensibleXMLObject.h"
+#include "AbstractComplexElement.h"
 #include "AbstractSimpleElement.h"
-#include "AbstractElementProxy.h"
 #include "exceptions.h"
 #include "io/AbstractXMLObjectMarshaller.h"
 #include "io/AbstractXMLObjectUnmarshaller.h"
@@ -36,6 +36,7 @@ using namespace soap11;
 using namespace xmltooling;
 using namespace std;
 using xmlconstants::SOAP11ENV_NS;
+using xmlconstants::SOAP11ENV_PREFIX;
 
 #if defined (_MSC_VER)
     #pragma warning( push )
@@ -86,8 +87,8 @@ namespace {
     };
 
     class XMLTOOL_DLLLOCAL DetailImpl : public virtual Detail,
-        public AbstractElementProxy,
         public AbstractAttributeExtensibleXMLObject,
+        public AbstractComplexElement,
         public AbstractDOMCachingXMLObject,
         public AbstractXMLObjectMarshaller,
         public AbstractXMLObjectUnmarshaller
@@ -101,17 +102,16 @@ namespace {
             
         DetailImpl(const DetailImpl& src)
                 : AbstractXMLObject(src),
-                    AbstractElementProxy(src),
                     AbstractAttributeExtensibleXMLObject(src),
+                    AbstractComplexElement(src),
                     AbstractDOMCachingXMLObject(src) {
-            for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
-                if (*i) {
-                    getXMLObjects().push_back((*i)->clone());
-                }
-            }
+            VectorOf(XMLObject) v=getUnknownXMLObjects();
+            for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
+                v.push_back((*i)->clone());
         }
         
         IMPL_XMLOBJECT_CLONE(Detail);
+        IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
 
     protected:
         void marshallAttributes(DOMElement* domElement) const {
@@ -119,7 +119,7 @@ namespace {
         }
 
         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-            getXMLObjects().push_back(childXMLObject);
+            getUnknownXMLObjects().push_back(childXMLObject);
         }
 
         void processAttribute(const DOMAttr* attribute) {
@@ -184,17 +184,17 @@ namespace {
 
     protected:
         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-            PROC_TYPED_CHILD(Faultcode,SOAP11ENV_NS,false);
-            PROC_TYPED_CHILD(Faultstring,SOAP11ENV_NS,false);
-            PROC_TYPED_CHILD(Faultactor,SOAP11ENV_NS,false);
-            PROC_TYPED_CHILD(Detail,SOAP11ENV_NS,false);
+            PROC_TYPED_CHILD(Faultcode,NULL,false);
+            PROC_TYPED_CHILD(Faultstring,NULL,false);
+            PROC_TYPED_CHILD(Faultactor,NULL,false);
+            PROC_TYPED_CHILD(Detail,NULL,false);
             AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
         }
     };
 
     class XMLTOOL_DLLLOCAL BodyImpl : public virtual Body,
-        public AbstractElementProxy,
         public AbstractAttributeExtensibleXMLObject,
+        public AbstractComplexElement,
         public AbstractDOMCachingXMLObject,
         public AbstractXMLObjectMarshaller,
         public AbstractXMLObjectUnmarshaller
@@ -214,29 +214,28 @@ namespace {
             
         BodyImpl(const BodyImpl& src)
                 : AbstractXMLObject(src),
-                    AbstractElementProxy(src),
                     AbstractAttributeExtensibleXMLObject(src),
+                    AbstractComplexElement(src),
                     AbstractDOMCachingXMLObject(src) {
             init();
             setEncodingStyle(src.getEncodingStyle());
-            for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
-                if (*i) {
-                    getXMLObjects().push_back((*i)->clone());
-                }
-            }
+            VectorOf(XMLObject) v=getUnknownXMLObjects();
+            for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
+                v.push_back((*i)->clone());
         }
         
         IMPL_XMLOBJECT_CLONE(Body);
         IMPL_STRING_ATTRIB(EncodingStyle);
+        IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
 
-        void setAttribute(QName& qualifiedName, const XMLCh* value) {
+        void setAttribute(QName& qualifiedName, const XMLCh* value, bool ID=false) {
             if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),SOAP11ENV_NS)) {
                 if (XMLString::equals(qualifiedName.getLocalPart(),ENCODINGSTYLE_ATTRIB_NAME)) {
                     setEncodingStyle(value);
                     return;
                 }
             }
-            AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+            AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
         }
 
     protected:
@@ -246,7 +245,7 @@ namespace {
         }
 
         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-            getXMLObjects().push_back(childXMLObject);
+            getUnknownXMLObjects().push_back(childXMLObject);
         }
 
         void processAttribute(const DOMAttr* attribute) {
@@ -255,8 +254,8 @@ namespace {
     };
 
     class XMLTOOL_DLLLOCAL HeaderImpl : public virtual Header,
-        public AbstractElementProxy,
         public AbstractAttributeExtensibleXMLObject,
+        public AbstractComplexElement,
         public AbstractDOMCachingXMLObject,
         public AbstractXMLObjectMarshaller,
         public AbstractXMLObjectUnmarshaller
@@ -277,24 +276,23 @@ namespace {
             
         HeaderImpl(const HeaderImpl& src)
                 : AbstractXMLObject(src),
-                    AbstractElementProxy(src),
                     AbstractAttributeExtensibleXMLObject(src),
+                    AbstractComplexElement(src),
                     AbstractDOMCachingXMLObject(src) {
             init();
             setActor(src.getActor());
             MustUnderstand(m_MustUnderstand);
-            for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
-                if (*i) {
-                    getXMLObjects().push_back((*i)->clone());
-                }
-            }
+            VectorOf(XMLObject) v=getUnknownXMLObjects();
+            for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
+                v.push_back((*i)->clone());
         }
         
         IMPL_XMLOBJECT_CLONE(Header);
         IMPL_STRING_ATTRIB(Actor);
         IMPL_BOOLEAN_ATTRIB(MustUnderstand);
+        IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
 
-        void setAttribute(QName& qualifiedName, const XMLCh* value) {
+        void setAttribute(QName& qualifiedName, const XMLCh* value, bool ID=false) {
             if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),SOAP11ENV_NS)) {
                 if (XMLString::equals(qualifiedName.getLocalPart(),MUSTUNDERSTAND_ATTRIB_NAME)) {
                     setMustUnderstand(value);
@@ -305,7 +303,7 @@ namespace {
                     return;
                 }
             }
-            AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
+            AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value, ID);
         }
 
     protected:
@@ -316,7 +314,7 @@ namespace {
         }
 
         void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
-            getXMLObjects().push_back(childXMLObject);
+            getUnknownXMLObjects().push_back(childXMLObject);
         }
 
         void processAttribute(const DOMAttr* attribute) {
@@ -412,3 +410,13 @@ const XMLCh Header::LOCAL_NAME[] =                      UNICODE_LITERAL_6(H,e,a,
 const XMLCh Header::TYPE_NAME[] =                       UNICODE_LITERAL_6(H,e,a,d,e,r);
 const XMLCh Header::ACTOR_ATTRIB_NAME[] =               UNICODE_LITERAL_5(a,c,t,o,r);
 const XMLCh Header::MUSTUNDERSTAND_ATTRIB_NAME[] =      UNICODE_LITERAL_14(m,u,s,t,U,n,d,e,r,s,t,a,n,d);
+
+static const XMLCh _CLIENT[] =                          UNICODE_LITERAL_6(C,l,i,e,n,t);\r
+static const XMLCh _SERVER[] =                          UNICODE_LITERAL_6(S,e,r,v,e,r);\r
+static const XMLCh _MUSTUNDERSTAND[] =                  UNICODE_LITERAL_14(M,u,s,t,U,n,d,e,r,s,t,a,n,d);\r
+static const XMLCh _VERSIONMISMATCH[] =                 UNICODE_LITERAL_15(V,e,r,s,i,o,n,M,i,s,m,a,t,c,h);\r
\r
+QName Faultcode::CLIENT(SOAP11ENV_NS,_CLIENT,SOAP11ENV_PREFIX);\r
+QName Faultcode::SERVER(SOAP11ENV_NS,_SERVER,SOAP11ENV_PREFIX);\r
+QName Faultcode::MUSTUNDERSTAND(SOAP11ENV_NS,_MUSTUNDERSTAND,SOAP11ENV_PREFIX);\r
+QName Faultcode::VERSIONMISMATCH(SOAP11ENV_NS,_VERSIONMISMATCH,SOAP11ENV_PREFIX);\r