From: Scott Cantor Date: Thu, 7 Sep 2006 03:50:47 +0000 (+0000) Subject: SOAP 1.1 classes X-Git-Tag: 1.0-alpha1~182 X-Git-Url: http://www.project-moonshot.org/gitweb/?p=shibboleth%2Fcpp-xmltooling.git;a=commitdiff_plain;h=f48caaeb67b63f254ea29ab55b883dc38a6f1761 SOAP 1.1 classes --- diff --git a/.cdtproject b/.cdtproject index b9e02ab..aa129f2 100644 --- a/.cdtproject +++ b/.cdtproject @@ -60,7 +60,7 @@ - + @@ -72,6 +72,8 @@ + + diff --git a/schemas/Makefile.am b/schemas/Makefile.am index d399785..79beb9f 100644 --- a/schemas/Makefile.am +++ b/schemas/Makefile.am @@ -28,8 +28,9 @@ CLEANFILES = catalog.xml EXTRA_DIST = \ catalog.xml.in \ + soap-envelope.xsd \ xenc-schema.xsd \ xmldsig-core-schema.xsd \ xml.xsd \ xmltooling.xsd - + \ No newline at end of file diff --git a/schemas/catalog.xml.in b/schemas/catalog.xml.in index 2521ae0..e140e05 100644 --- a/schemas/catalog.xml.in +++ b/schemas/catalog.xml.in @@ -5,4 +5,5 @@ + diff --git a/schemas/soap-envelope.xsd b/schemas/soap-envelope.xsd new file mode 100644 index 0000000..224e815 --- /dev/null +++ b/schemas/soap-envelope.xsd @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Prose in the spec does not specify that attributes are allowed on the Body element + + + + + + + + + + + + + + + + + + + + 'encodingStyle' indicates any canonicalization conventions followed in the contents of the containing element. For example, the value 'http://schemas.xmlsoap.org/soap/encoding/' indicates the pattern described in SOAP specification + + + + + + + + + + + + + + + Fault reporting structure + + + + + + + + + + + + + + + + + + + diff --git a/xmltooling/Makefile.am b/xmltooling/Makefile.am index 07b843e..7aeccb8 100644 --- a/xmltooling/Makefile.am +++ b/xmltooling/Makefile.am @@ -72,6 +72,9 @@ siginclude_HEADERS = \ signature/Signature.h \ signature/SignatureValidator.h +soapinclude_HEADERS = \ + soap/SOAP.h + utilinclude_HEADERS = \ util/DateTime.h \ util/NDC.h \ @@ -132,6 +135,8 @@ libxmltooling_la_SOURCES = \ io/AbstractXMLObjectUnmarshaller.cpp \ signature/impl/KeyInfoImpl.cpp \ signature/impl/KeyInfoSchemaValidators.cpp \ + soap/impl/SOAPImpl.cpp \ + soap/impl/SOAPSchemaValidators.cpp \ util/DateTime.cpp \ util/NDC.cpp \ util/ParserPool.cpp \ diff --git a/xmltooling/XMLToolingConfig.cpp b/xmltooling/XMLToolingConfig.cpp index ce58432..9477479 100644 --- a/xmltooling/XMLToolingConfig.cpp +++ b/xmltooling/XMLToolingConfig.cpp @@ -28,6 +28,7 @@ #include "security/TrustEngine.h" #include "security/OpenSSLCryptoX509CRL.h" #include "signature/CredentialResolver.h" +#include "soap/SOAP.h" #include "util/NDC.h" #include "util/XMLConstants.h" #include "validation/Validator.h" @@ -46,6 +47,7 @@ #include #endif +using namespace soap11; using namespace xmlencryption; using namespace xmlsignature; using namespace xmltooling; @@ -165,6 +167,7 @@ bool XMLToolingInternalConfig::init() registerKeyInfoClasses(); registerEncryptionClasses(); + registerSOAPClasses(); REGISTER_EXCEPTION_FACTORY(XMLParserException,xmltooling); REGISTER_EXCEPTION_FACTORY(XMLObjectException,xmltooling); diff --git a/xmltooling/soap/SOAP.h b/xmltooling/soap/SOAP.h new file mode 100644 index 0000000..8baa83e --- /dev/null +++ b/xmltooling/soap/SOAP.h @@ -0,0 +1,107 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file SOAP.h + * + * XMLObjects representing SOAP content + */ + +#ifndef __xmltooling_soap_h__ +#define __xmltooling_soap_h__ + +#include +#include +#include +#include +#include +#include +#include + +#define DECL_SOAP11OBJECTBUILDER(cname) \ + DECL_XMLOBJECTBUILDER(XMLTOOL_API,cname,xmltooling::XMLConstants::SOAP11ENV_NS,xmltooling::XMLConstants::SOAP11ENV_PREFIX) + +/** + * @namespace soap11 + * Namespace for SOAP 1.1 schema objects + */ +namespace soap11 { + + DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Faultstring,String,SOAP 1.1 faultstring element); + DECL_XMLOBJECT_SIMPLE(XMLTOOL_API,Faultactor,Actor,SOAP 1.1 faultactor element); + + BEGIN_XMLOBJECT(XMLTOOL_API,Faultcode,xmltooling::XMLObject,SOAP 1.1 faultcode element); + /** Gets the QName content of the element. */ + virtual xmltooling::QName* getCode() const=0; + /** Sets the QName content of the element. */ + virtual void setCode(const xmltooling::QName* qname)=0; + END_XMLOBJECT; + + BEGIN_XMLOBJECT2(XMLTOOL_API,Detail,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SOAP 1.1 detail element); + /** detail (type) local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(XMLTOOL_API,Fault,xmltooling::XMLObject,SOAP 1.1 Fault element); + DECL_TYPED_CHILD(Faultcode); + DECL_TYPED_CHILD(Faultstring); + DECL_TYPED_CHILD(Faultactor); + DECL_TYPED_CHILD(Detail); + /** Fault (type) local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT2(XMLTOOL_API,Body,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SOAP 1.1 Body element); + DECL_STRING_ATTRIB(EncodingStyle,ENCODINGSTYLE); + /** Body (type) local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT2(XMLTOOL_API,Header,xmltooling::ElementProxy,xmltooling::AttributeExtensibleXMLObject,SOAP 1.1 Header element); + DECL_BOOLEAN_ATTRIB(MustUnderstand,MUSTUNDERSTAND,false); + DECL_STRING_ATTRIB(Actor,ACTOR); + /** Header (type) local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + BEGIN_XMLOBJECT(XMLTOOL_API,Envelope,xmltooling::AttributeExtensibleXMLObject,SOAP 1.1 Envelope element); + DECL_TYPED_CHILD(Header); + DECL_TYPED_CHILD(Body); + /** Envelope (type) local name */ + static const XMLCh TYPE_NAME[]; + END_XMLOBJECT; + + DECL_SOAP11OBJECTBUILDER(Body); + DECL_SOAP11OBJECTBUILDER(Detail); + DECL_SOAP11OBJECTBUILDER(Envelope); + DECL_SOAP11OBJECTBUILDER(Fault); + DECL_SOAP11OBJECTBUILDER(Faultactor); + DECL_SOAP11OBJECTBUILDER(Faultcode); + DECL_SOAP11OBJECTBUILDER(Faultstring); + DECL_SOAP11OBJECTBUILDER(Header); + + /** + * Registers builders and validators for SOAP 1.1 classes into the runtime. + */ + void XMLTOOL_API registerSOAPClasses(); + + /** + * Validator suite for SOAP 1.1 schema validation. + */ + extern XMLTOOL_API xmltooling::ValidatorSuite SOAPSchemaValidators; +}; + +#endif /* __xmltooling_soap_h__ */ diff --git a/xmltooling/soap/impl/SOAPImpl.cpp b/xmltooling/soap/impl/SOAPImpl.cpp new file mode 100644 index 0000000..1f4ec07 --- /dev/null +++ b/xmltooling/soap/impl/SOAPImpl.cpp @@ -0,0 +1,447 @@ +/* + * Copyright 2001-2006 Internet2 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SOAPImpl.cpp + * + * Implementation classes for SOAP schema + */ + +#include "internal.h" +#include "AbstractAttributeExtensibleXMLObject.h" +#include "AbstractChildlessElement.h" +#include "AbstractElementProxy.h" +#include "exceptions.h" +#include "io/AbstractXMLObjectMarshaller.h" +#include "io/AbstractXMLObjectUnmarshaller.h" +#include "soap/SOAP.h" +#include "util/XMLHelper.h" + +#include + +using namespace soap11; +using namespace xmltooling; +using namespace std; + +#if defined (_MSC_VER) + #pragma warning( push ) + #pragma warning( disable : 4250 4251 ) +#endif + +namespace { + + DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Faultstring); + DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Faultactor); + + class XMLTOOL_DLLLOCAL FaultcodeImpl : public virtual Faultcode, + protected AbstractSimpleElement, + public AbstractChildlessElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + QName* m_qname; + public: + virtual ~FaultcodeImpl() { + delete m_qname; + } + + FaultcodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_qname(NULL) { + } + + FaultcodeImpl(const FaultcodeImpl& src) + : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src), m_qname(NULL) { + setCode(src.getCode()); + } + + QName* getCode() const { + return m_qname; + } + + void setCode(const QName* qname) { + m_qname=prepareForAssignment(m_qname,qname); + if (m_qname) { + auto_ptr_XMLCh temp(m_qname->toString().c_str()); + setTextContent(temp.get()); + } + else + setTextContent(NULL); + } + + IMPL_XMLOBJECT_CLONE(Faultcode); + IMPL_XMLOBJECT_CONTENT; + }; + + class XMLTOOL_DLLLOCAL DetailImpl : public virtual Detail, + public AbstractElementProxy, + public AbstractAttributeExtensibleXMLObject, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + public: + virtual ~DetailImpl() {} + + DetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + } + + DetailImpl(const DetailImpl& src) + : AbstractXMLObject(src), + AbstractElementProxy(src), + AbstractAttributeExtensibleXMLObject(src), + AbstractDOMCachingXMLObject(src) { + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + getXMLObjects().push_back((*i)->clone()); + } + } + } + + IMPL_XMLOBJECT_CLONE(Detail); + + protected: + void marshallAttributes(DOMElement* domElement) const { + // Take care of wildcard. + for (map::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) { + DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart()); + if (i->first.hasPrefix()) + attr->setPrefix(i->first.getPrefix()); + attr->setNodeValue(i->second); + domElement->setAttributeNode(attr); + } + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + getXMLObjects().push_back(childXMLObject); + } + + void processAttribute(const DOMAttr* attribute) { + QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); + setAttribute(q,attribute->getNodeValue()); + } + }; + + class XMLTOOL_DLLLOCAL FaultImpl : public virtual Fault, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_Faultcode=NULL; + m_Faultstring=NULL; + m_Faultactor=NULL; + m_Detail=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_Faultcode=m_children.begin(); + m_pos_Faultstring=m_pos_Faultcode; + ++m_pos_Faultstring; + m_pos_Faultactor=m_pos_Faultstring; + ++m_pos_Faultactor; + m_pos_Detail=m_pos_Faultactor; + ++m_pos_Detail; + } + protected: + FaultImpl() { + init(); + } + + public: + virtual ~FaultImpl() {} + + FaultImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } + + FaultImpl(const FaultImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) { + init(); + if (src.getFaultcode()) + setFaultcode(src.getFaultcode()->cloneFaultcode()); + if (src.getFaultstring()) + setFaultstring(src.getFaultstring()->cloneFaultstring()); + if (src.getFaultactor()) + setFaultactor(src.getFaultactor()->cloneFaultactor()); + if (src.getDetail()) + setDetail(src.getDetail()->cloneDetail()); + } + + IMPL_XMLOBJECT_CLONE(Fault); + IMPL_TYPED_CHILD(Faultcode); + IMPL_TYPED_CHILD(Faultstring); + IMPL_TYPED_CHILD(Faultactor); + IMPL_TYPED_CHILD(Detail); + + protected: + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILD(Faultcode,XMLConstants::SOAP11ENV_NS,false); + PROC_TYPED_CHILD(Faultstring,XMLConstants::SOAP11ENV_NS,false); + PROC_TYPED_CHILD(Faultactor,XMLConstants::SOAP11ENV_NS,false); + PROC_TYPED_CHILD(Detail,XMLConstants::SOAP11ENV_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + }; + + class XMLTOOL_DLLLOCAL BodyImpl : public virtual Body, + public AbstractElementProxy, + public AbstractAttributeExtensibleXMLObject, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_EncodingStyle=NULL; + } + public: + virtual ~BodyImpl() { + XMLString::release(&m_EncodingStyle); + } + + BodyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } + + BodyImpl(const BodyImpl& src) + : AbstractXMLObject(src), + AbstractElementProxy(src), + AbstractAttributeExtensibleXMLObject(src), + AbstractDOMCachingXMLObject(src) { + init(); + setEncodingStyle(src.getEncodingStyle()); + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + getXMLObjects().push_back((*i)->clone()); + } + } + } + + IMPL_XMLOBJECT_CLONE(Body); + IMPL_STRING_ATTRIB(EncodingStyle); + + void setAttribute(QName& qualifiedName, const XMLCh* value) { + if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),XMLConstants::SOAP11ENV_NS)) { + if (XMLString::equals(qualifiedName.getLocalPart(),ENCODINGSTYLE_ATTRIB_NAME)) { + setEncodingStyle(value); + return; + } + } + AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value); + } + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(EncodingStyle,ENCODINGSTYLE,XMLConstants::SOAP11ENV_NS); + + // Take care of wildcard. + for (map::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) { + DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart()); + if (i->first.hasPrefix()) + attr->setPrefix(i->first.getPrefix()); + attr->setNodeValue(i->second); + domElement->setAttributeNode(attr); + } + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + getXMLObjects().push_back(childXMLObject); + } + + void processAttribute(const DOMAttr* attribute) { + QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); + setAttribute(q,attribute->getNodeValue()); + } + }; + + class XMLTOOL_DLLLOCAL HeaderImpl : public virtual Header, + public AbstractElementProxy, + public AbstractAttributeExtensibleXMLObject, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_Actor=NULL; + m_MustUnderstand=XMLConstants::XML_BOOL_NULL; + } + public: + virtual ~HeaderImpl() { + XMLString::release(&m_Actor); + } + + HeaderImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } + + HeaderImpl(const HeaderImpl& src) + : AbstractXMLObject(src), + AbstractElementProxy(src), + AbstractAttributeExtensibleXMLObject(src), + AbstractDOMCachingXMLObject(src) { + init(); + setActor(src.getActor()); + MustUnderstand(m_MustUnderstand); + for (list::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) { + if (*i) { + getXMLObjects().push_back((*i)->clone()); + } + } + } + + IMPL_XMLOBJECT_CLONE(Header); + IMPL_STRING_ATTRIB(Actor); + IMPL_BOOLEAN_ATTRIB(MustUnderstand); + + void setAttribute(QName& qualifiedName, const XMLCh* value) { + if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),XMLConstants::SOAP11ENV_NS)) { + if (XMLString::equals(qualifiedName.getLocalPart(),MUSTUNDERSTAND_ATTRIB_NAME)) { + setMustUnderstand(value); + return; + } + else if (XMLString::equals(qualifiedName.getLocalPart(),ACTOR_ATTRIB_NAME)) { + setActor(value); + return; + } + } + AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value); + } + + protected: + void marshallAttributes(DOMElement* domElement) const { + MARSHALL_STRING_ATTRIB(Actor,ACTOR,XMLConstants::SOAP11ENV_NS); + MARSHALL_BOOLEAN_ATTRIB(MustUnderstand,MUSTUNDERSTAND,XMLConstants::SOAP11ENV_NS); + + // Take care of wildcard. + for (map::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) { + DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart()); + if (i->first.hasPrefix()) + attr->setPrefix(i->first.getPrefix()); + attr->setNodeValue(i->second); + domElement->setAttributeNode(attr); + } + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + getXMLObjects().push_back(childXMLObject); + } + + void processAttribute(const DOMAttr* attribute) { + QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); + setAttribute(q,attribute->getNodeValue()); + } + }; + + class XMLTOOL_DLLLOCAL EnvelopeImpl : public virtual Envelope, + public AbstractAttributeExtensibleXMLObject, + public AbstractComplexElement, + public AbstractDOMCachingXMLObject, + public AbstractXMLObjectMarshaller, + public AbstractXMLObjectUnmarshaller + { + void init() { + m_Header=NULL; + m_Body=NULL; + m_children.push_back(NULL); + m_children.push_back(NULL); + m_pos_Header=m_children.begin(); + m_pos_Body=m_pos_Header; + ++m_pos_Body; + } + public: + virtual ~EnvelopeImpl() {} + + EnvelopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType) + : AbstractXMLObject(nsURI, localName, prefix, schemaType) { + init(); + } + + EnvelopeImpl(const EnvelopeImpl& src) + : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) { + init(); + if (src.getHeader()) + setHeader(src.getHeader()->cloneHeader()); + if (src.getBody()) + setBody(src.getBody()->cloneBody()); + } + + IMPL_TYPED_CHILD(Header); + IMPL_TYPED_CHILD(Body); + IMPL_XMLOBJECT_CLONE(Envelope); + + protected: + void marshallAttributes(DOMElement* domElement) const { + // Take care of wildcard. + for (map::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) { + DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart()); + if (i->first.hasPrefix()) + attr->setPrefix(i->first.getPrefix()); + attr->setNodeValue(i->second); + domElement->setAttributeNode(attr); + } + } + + void processChildElement(XMLObject* childXMLObject, const DOMElement* root) { + PROC_TYPED_CHILD(Header,XMLConstants::SOAP11ENV_NS,false); + PROC_TYPED_CHILD(Body,XMLConstants::SOAP11ENV_NS,false); + AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root); + } + + void processAttribute(const DOMAttr* attribute) { + QName q(attribute->getNamespaceURI(),attribute->getLocalName(),attribute->getPrefix()); + setAttribute(q,attribute->getNodeValue()); + } + }; +}; + +#if defined (_MSC_VER) + #pragma warning( pop ) +#endif + +// Builder Implementations + +IMPL_XMLOBJECTBUILDER(Body); +IMPL_XMLOBJECTBUILDER(Detail); +IMPL_XMLOBJECTBUILDER(Envelope); +IMPL_XMLOBJECTBUILDER(Fault); +IMPL_XMLOBJECTBUILDER(Faultactor); +IMPL_XMLOBJECTBUILDER(Faultcode); +IMPL_XMLOBJECTBUILDER(Faultstring); +IMPL_XMLOBJECTBUILDER(Header); + +// Unicode literals + +const XMLCh Body::LOCAL_NAME[] = UNICODE_LITERAL_4(B,o,d,y); +const XMLCh Body::TYPE_NAME[] = UNICODE_LITERAL_4(B,o,d,y); +const XMLCh Body::ENCODINGSTYLE_ATTRIB_NAME[] = UNICODE_LITERAL_13(e,n,c,o,d,i,n,g,S,t,y,l,e); +const XMLCh Detail::LOCAL_NAME[] = UNICODE_LITERAL_6(d,e,t,a,i,l); +const XMLCh Detail::TYPE_NAME[] = UNICODE_LITERAL_6(d,e,t,a,i,l); +const XMLCh Envelope::LOCAL_NAME[] = UNICODE_LITERAL_8(E,n,v,e,l,o,p,e); +const XMLCh Envelope::TYPE_NAME[] = UNICODE_LITERAL_8(E,n,v,e,l,o,p,e); +const XMLCh Fault::LOCAL_NAME[] = UNICODE_LITERAL_5(F,a,u,l,t); +const XMLCh Fault::TYPE_NAME[] = UNICODE_LITERAL_5(F,a,u,l,t); +const XMLCh Faultactor::LOCAL_NAME[] = UNICODE_LITERAL_10(F,a,u,l,t,a,c,t,o,r); +const XMLCh Faultcode::LOCAL_NAME[] = UNICODE_LITERAL_9(F,a,u,l,t,c,o,d,e); +const XMLCh Faultstring::LOCAL_NAME[] = UNICODE_LITERAL_11(F,a,u,l,t,s,t,r,i,n,g); +const XMLCh Header::LOCAL_NAME[] = UNICODE_LITERAL_6(H,e,a,d,e,r); +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); diff --git a/xmltooling/soap/impl/SOAPSchemaValidators.cpp b/xmltooling/soap/impl/SOAPSchemaValidators.cpp new file mode 100644 index 0000000..bd4f71e --- /dev/null +++ b/xmltooling/soap/impl/SOAPSchemaValidators.cpp @@ -0,0 +1,87 @@ +/* +* Copyright 2001-2006 Internet2 + * +* Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * SOAPSchemaValidators.cpp + * + * Schema validators for SOAP schema + */ + +#include "internal.h" +#include "exceptions.h" +#include "soap/SOAP.h" + +using namespace soap11; +using namespace xmltooling; +using namespace std; + +namespace { + + XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,Faultstring); + XMLOBJECTVALIDATOR_SIMPLE(XMLTOOL_DLLLOCAL,Faultactor); + + BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Faultcode); + XMLOBJECTVALIDATOR_REQUIRE(Faultcode,Code); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Fault); + XMLOBJECTVALIDATOR_REQUIRE(Fault,Faultcode); + XMLOBJECTVALIDATOR_REQUIRE(Fault,Faultstring); + END_XMLOBJECTVALIDATOR; + + BEGIN_XMLOBJECTVALIDATOR(XMLTOOL_DLLLOCAL,Envelope); + XMLOBJECTVALIDATOR_REQUIRE(Envelope,Body); + END_XMLOBJECTVALIDATOR; + +}; + +#define REGISTER_ELEMENT(namespaceURI,cname) \ + q=QName(namespaceURI,cname::LOCAL_NAME); \ + XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ + SOAPSchemaValidators.registerValidator(q,new cname##SchemaValidator()) + +#define REGISTER_TYPE(namespaceURI,cname) \ + q=QName(namespaceURI,cname::TYPE_NAME); \ + XMLObjectBuilder::registerBuilder(q,new cname##Builder()); \ + SOAPSchemaValidators.registerValidator(q,new cname##SchemaValidator()) + +#define REGISTER_ELEMENT_NOVAL(namespaceURI,cname) \ + q=QName(namespaceURI,cname::LOCAL_NAME); \ + XMLObjectBuilder::registerBuilder(q,new cname##Builder()); + +#define REGISTER_TYPE_NOVAL(namespaceURI,cname) \ + q=QName(namespaceURI,cname::TYPE_NAME); \ + XMLObjectBuilder::registerBuilder(q,new cname##Builder()); + +ValidatorSuite soap11::SOAPSchemaValidators("SOAPSchemaValidators"); + +void soap11::registerSOAPClasses() +{ + QName q; + REGISTER_ELEMENT_NOVAL(XMLConstants::SOAP11ENV_NS,Body); + REGISTER_ELEMENT_NOVAL(XMLConstants::SOAP11ENV_NS,Detail); + REGISTER_ELEMENT(XMLConstants::SOAP11ENV_NS,Envelope); + REGISTER_ELEMENT(XMLConstants::SOAP11ENV_NS,Fault); + REGISTER_ELEMENT(XMLConstants::SOAP11ENV_NS,Faultactor); + REGISTER_ELEMENT(XMLConstants::SOAP11ENV_NS,Faultcode); + REGISTER_ELEMENT(XMLConstants::SOAP11ENV_NS,Faultstring); + REGISTER_ELEMENT_NOVAL(XMLConstants::SOAP11ENV_NS,Header); + REGISTER_TYPE_NOVAL(XMLConstants::SOAP11ENV_NS,Body); + REGISTER_TYPE_NOVAL(XMLConstants::SOAP11ENV_NS,Detail); + REGISTER_TYPE(XMLConstants::SOAP11ENV_NS,Envelope); + REGISTER_TYPE(XMLConstants::SOAP11ENV_NS,Fault); + REGISTER_TYPE_NOVAL(XMLConstants::SOAP11ENV_NS,Header); +} diff --git a/xmltooling/util/XMLConstants.cpp b/xmltooling/util/XMLConstants.cpp index 847acb6..232c8d5 100644 --- a/xmltooling/util/XMLConstants.cpp +++ b/xmltooling/util/XMLConstants.cpp @@ -82,6 +82,17 @@ const XMLCh XMLConstants::XMLENC_NS[] = // http://www.w3.org/2001/04/xmlenc# const XMLCh XMLConstants::XMLENC_PREFIX[] = { chLatin_x, chLatin_e, chLatin_n, chLatin_c, chNull }; +const XMLCh XMLConstants::SOAP11ENV_NS[] = // http://schemas.xmlsoap.org/soap/envelope/ +{ chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, + chLatin_s, chLatin_c, chLatin_h, chLatin_e, chLatin_m, chLatin_a, chLatin_s, chPeriod, + chLatin_x, chLatin_m, chLatin_l, chLatin_s, chLatin_o, chLatin_a, chLatin_p, chPeriod, + chLatin_o, chLatin_r, chLatin_g, chForwardSlash, + chLatin_s, chLatin_o, chLatin_a, chLatin_p, chForwardSlash, + chLatin_e, chLatin_n, chLatin_v, chLatin_e, chLatin_l, chLatin_o, chLatin_p, chLatin_e, chForwardSlash, chNull +}; + +const XMLCh XMLConstants::SOAP11ENV_PREFIX[] = UNICODE_LITERAL_1(S); + const XMLCh XMLConstants::XMLTOOLING_NS[] = // http://www.opensaml.org/xmltooling { chLatin_h, chLatin_t, chLatin_t, chLatin_p, chColon, chForwardSlash, chForwardSlash, chLatin_w, chLatin_w, chLatin_w, chPeriod, diff --git a/xmltooling/util/XMLConstants.h b/xmltooling/util/XMLConstants.h index 028c4b3..355ec39 100644 --- a/xmltooling/util/XMLConstants.h +++ b/xmltooling/util/XMLConstants.h @@ -68,6 +68,12 @@ namespace xmltooling { /** XML Encryption QName prefix ("xenc") */ static const XMLCh XMLENC_PREFIX[]; + /** SOAP 1.1 Envelope XML namespace ("http://schemas.xmlsoap.org/soap/envelope/") */ + static const XMLCh SOAP11ENV_NS[]; + + /** SOAP 1.1 Envelope QName prefix ("S") */ + static const XMLCh SOAP11ENV_PREFIX[]; + /** XML Tooling namespace ("http://www.opensaml.org/xmltooling") */ static const XMLCh XMLTOOLING_NS[]; diff --git a/xmltooling/xmltooling.vcproj b/xmltooling/xmltooling.vcproj index 4e865e9..8fdc20e 100644 --- a/xmltooling/xmltooling.vcproj +++ b/xmltooling/xmltooling.vcproj @@ -373,6 +373,22 @@ + + + + + + + + + + + +