2 * Copyright 2001-2006 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 * Implementation classes for SOAP schema
24 #include "AbstractAttributeExtensibleXMLObject.h"
25 #include "AbstractComplexElement.h"
26 #include "AbstractSimpleElement.h"
27 #include "exceptions.h"
28 #include "io/AbstractXMLObjectMarshaller.h"
29 #include "io/AbstractXMLObjectUnmarshaller.h"
30 #include "soap/SOAP.h"
31 #include "util/XMLHelper.h"
33 #include <xercesc/util/XMLUniDefs.hpp>
35 using namespace soap11;
36 using namespace xmltooling;
38 using xmlconstants::SOAP11ENV_NS;
40 #if defined (_MSC_VER)
41 #pragma warning( push )
42 #pragma warning( disable : 4250 4251 )
47 DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Faultstring);
48 DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Faultactor);
50 class XMLTOOL_DLLLOCAL FaultcodeImpl : public virtual Faultcode,
51 public AbstractSimpleElement,
52 public AbstractDOMCachingXMLObject,
53 public AbstractXMLObjectMarshaller,
54 public AbstractXMLObjectUnmarshaller
58 virtual ~FaultcodeImpl() {
62 FaultcodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
63 : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_qname(NULL) {
66 FaultcodeImpl(const FaultcodeImpl& src)
67 : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src), m_qname(NULL) {
68 setCode(src.getCode());
71 const QName* getCode() const {
75 void setCode(const QName* qname) {
76 m_qname=prepareForAssignment(m_qname,qname);
78 auto_ptr_XMLCh temp(m_qname->toString().c_str());
79 setTextContent(temp.get());
85 IMPL_XMLOBJECT_CLONE(Faultcode);
88 class XMLTOOL_DLLLOCAL DetailImpl : public virtual Detail,
89 public AbstractAttributeExtensibleXMLObject,
90 public AbstractComplexElement,
91 public AbstractDOMCachingXMLObject,
92 public AbstractXMLObjectMarshaller,
93 public AbstractXMLObjectUnmarshaller
96 virtual ~DetailImpl() {}
98 DetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
99 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
102 DetailImpl(const DetailImpl& src)
103 : AbstractXMLObject(src),
104 AbstractAttributeExtensibleXMLObject(src),
105 AbstractComplexElement(src),
106 AbstractDOMCachingXMLObject(src) {
107 VectorOf(XMLObject) v=getUnknownXMLObjects();
108 for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
109 v.push_back((*i)->clone());
112 IMPL_XMLOBJECT_CLONE(Detail);
113 IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
116 void marshallAttributes(DOMElement* domElement) const {
117 marshallExtensionAttributes(domElement);
120 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
121 getUnknownXMLObjects().push_back(childXMLObject);
124 void processAttribute(const DOMAttr* attribute) {
125 unmarshallExtensionAttribute(attribute);
129 class XMLTOOL_DLLLOCAL FaultImpl : public virtual Fault,
130 public AbstractComplexElement,
131 public AbstractDOMCachingXMLObject,
132 public AbstractXMLObjectMarshaller,
133 public AbstractXMLObjectUnmarshaller
140 m_children.push_back(NULL);
141 m_children.push_back(NULL);
142 m_children.push_back(NULL);
143 m_children.push_back(NULL);
144 m_pos_Faultcode=m_children.begin();
145 m_pos_Faultstring=m_pos_Faultcode;
147 m_pos_Faultactor=m_pos_Faultstring;
149 m_pos_Detail=m_pos_Faultactor;
158 virtual ~FaultImpl() {}
160 FaultImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
161 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
165 FaultImpl(const FaultImpl& src)
166 : AbstractXMLObject(src), AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
168 if (src.getFaultcode())
169 setFaultcode(src.getFaultcode()->cloneFaultcode());
170 if (src.getFaultstring())
171 setFaultstring(src.getFaultstring()->cloneFaultstring());
172 if (src.getFaultactor())
173 setFaultactor(src.getFaultactor()->cloneFaultactor());
175 setDetail(src.getDetail()->cloneDetail());
178 IMPL_XMLOBJECT_CLONE(Fault);
179 IMPL_TYPED_CHILD(Faultcode);
180 IMPL_TYPED_CHILD(Faultstring);
181 IMPL_TYPED_CHILD(Faultactor);
182 IMPL_TYPED_CHILD(Detail);
185 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
186 PROC_TYPED_CHILD(Faultcode,SOAP11ENV_NS,false);
187 PROC_TYPED_CHILD(Faultstring,SOAP11ENV_NS,false);
188 PROC_TYPED_CHILD(Faultactor,SOAP11ENV_NS,false);
189 PROC_TYPED_CHILD(Detail,SOAP11ENV_NS,false);
190 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
194 class XMLTOOL_DLLLOCAL BodyImpl : public virtual Body,
195 public AbstractAttributeExtensibleXMLObject,
196 public AbstractComplexElement,
197 public AbstractDOMCachingXMLObject,
198 public AbstractXMLObjectMarshaller,
199 public AbstractXMLObjectUnmarshaller
202 m_EncodingStyle=NULL;
205 virtual ~BodyImpl() {
206 XMLString::release(&m_EncodingStyle);
209 BodyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
210 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
214 BodyImpl(const BodyImpl& src)
215 : AbstractXMLObject(src),
216 AbstractAttributeExtensibleXMLObject(src),
217 AbstractComplexElement(src),
218 AbstractDOMCachingXMLObject(src) {
220 setEncodingStyle(src.getEncodingStyle());
221 VectorOf(XMLObject) v=getUnknownXMLObjects();
222 for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
223 v.push_back((*i)->clone());
226 IMPL_XMLOBJECT_CLONE(Body);
227 IMPL_STRING_ATTRIB(EncodingStyle);
228 IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
230 void setAttribute(QName& qualifiedName, const XMLCh* value) {
231 if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),SOAP11ENV_NS)) {
232 if (XMLString::equals(qualifiedName.getLocalPart(),ENCODINGSTYLE_ATTRIB_NAME)) {
233 setEncodingStyle(value);
237 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
241 void marshallAttributes(DOMElement* domElement) const {
242 MARSHALL_STRING_ATTRIB(EncodingStyle,ENCODINGSTYLE,SOAP11ENV_NS);
243 marshallExtensionAttributes(domElement);
246 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
247 getUnknownXMLObjects().push_back(childXMLObject);
250 void processAttribute(const DOMAttr* attribute) {
251 unmarshallExtensionAttribute(attribute);
255 class XMLTOOL_DLLLOCAL HeaderImpl : public virtual Header,
256 public AbstractAttributeExtensibleXMLObject,
257 public AbstractComplexElement,
258 public AbstractDOMCachingXMLObject,
259 public AbstractXMLObjectMarshaller,
260 public AbstractXMLObjectUnmarshaller
264 m_MustUnderstand=xmlconstants::XML_BOOL_NULL;
267 virtual ~HeaderImpl() {
268 XMLString::release(&m_Actor);
271 HeaderImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
272 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
276 HeaderImpl(const HeaderImpl& src)
277 : AbstractXMLObject(src),
278 AbstractAttributeExtensibleXMLObject(src),
279 AbstractComplexElement(src),
280 AbstractDOMCachingXMLObject(src) {
282 setActor(src.getActor());
283 MustUnderstand(m_MustUnderstand);
284 VectorOf(XMLObject) v=getUnknownXMLObjects();
285 for (vector<XMLObject*>::const_iterator i=src.m_UnknownXMLObjects.begin(); i!=src.m_UnknownXMLObjects.end(); ++i)
286 v.push_back((*i)->clone());
289 IMPL_XMLOBJECT_CLONE(Header);
290 IMPL_STRING_ATTRIB(Actor);
291 IMPL_BOOLEAN_ATTRIB(MustUnderstand);
292 IMPL_XMLOBJECT_CHILDREN(UnknownXMLObject, m_children.end());
294 void setAttribute(QName& qualifiedName, const XMLCh* value) {
295 if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),SOAP11ENV_NS)) {
296 if (XMLString::equals(qualifiedName.getLocalPart(),MUSTUNDERSTAND_ATTRIB_NAME)) {
297 setMustUnderstand(value);
300 else if (XMLString::equals(qualifiedName.getLocalPart(),ACTOR_ATTRIB_NAME)) {
305 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
309 void marshallAttributes(DOMElement* domElement) const {
310 MARSHALL_STRING_ATTRIB(Actor,ACTOR,SOAP11ENV_NS);
311 MARSHALL_BOOLEAN_ATTRIB(MustUnderstand,MUSTUNDERSTAND,SOAP11ENV_NS);
312 marshallExtensionAttributes(domElement);
315 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
316 getUnknownXMLObjects().push_back(childXMLObject);
319 void processAttribute(const DOMAttr* attribute) {
320 unmarshallExtensionAttribute(attribute);
324 class XMLTOOL_DLLLOCAL EnvelopeImpl : public virtual Envelope,
325 public AbstractAttributeExtensibleXMLObject,
326 public AbstractComplexElement,
327 public AbstractDOMCachingXMLObject,
328 public AbstractXMLObjectMarshaller,
329 public AbstractXMLObjectUnmarshaller
334 m_children.push_back(NULL);
335 m_children.push_back(NULL);
336 m_pos_Header=m_children.begin();
337 m_pos_Body=m_pos_Header;
341 virtual ~EnvelopeImpl() {}
343 EnvelopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
344 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
348 EnvelopeImpl(const EnvelopeImpl& src)
349 : AbstractXMLObject(src), AbstractAttributeExtensibleXMLObject(src),
350 AbstractComplexElement(src), AbstractDOMCachingXMLObject(src) {
353 setHeader(src.getHeader()->cloneHeader());
355 setBody(src.getBody()->cloneBody());
358 IMPL_TYPED_CHILD(Header);
359 IMPL_TYPED_CHILD(Body);
360 IMPL_XMLOBJECT_CLONE(Envelope);
363 void marshallAttributes(DOMElement* domElement) const {
364 marshallExtensionAttributes(domElement);
367 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
368 PROC_TYPED_CHILD(Header,SOAP11ENV_NS,false);
369 PROC_TYPED_CHILD(Body,SOAP11ENV_NS,false);
370 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
373 void processAttribute(const DOMAttr* attribute) {
374 unmarshallExtensionAttribute(attribute);
379 #if defined (_MSC_VER)
380 #pragma warning( pop )
383 // Builder Implementations
385 IMPL_XMLOBJECTBUILDER(Body);
386 IMPL_XMLOBJECTBUILDER(Detail);
387 IMPL_XMLOBJECTBUILDER(Envelope);
388 IMPL_XMLOBJECTBUILDER(Fault);
389 IMPL_XMLOBJECTBUILDER(Faultactor);
390 IMPL_XMLOBJECTBUILDER(Faultcode);
391 IMPL_XMLOBJECTBUILDER(Faultstring);
392 IMPL_XMLOBJECTBUILDER(Header);
396 const XMLCh Body::LOCAL_NAME[] = UNICODE_LITERAL_4(B,o,d,y);
397 const XMLCh Body::TYPE_NAME[] = UNICODE_LITERAL_4(B,o,d,y);
398 const XMLCh Body::ENCODINGSTYLE_ATTRIB_NAME[] = UNICODE_LITERAL_13(e,n,c,o,d,i,n,g,S,t,y,l,e);
399 const XMLCh Detail::LOCAL_NAME[] = UNICODE_LITERAL_6(d,e,t,a,i,l);
400 const XMLCh Detail::TYPE_NAME[] = UNICODE_LITERAL_6(d,e,t,a,i,l);
401 const XMLCh Envelope::LOCAL_NAME[] = UNICODE_LITERAL_8(E,n,v,e,l,o,p,e);
402 const XMLCh Envelope::TYPE_NAME[] = UNICODE_LITERAL_8(E,n,v,e,l,o,p,e);
403 const XMLCh Fault::LOCAL_NAME[] = UNICODE_LITERAL_5(F,a,u,l,t);
404 const XMLCh Fault::TYPE_NAME[] = UNICODE_LITERAL_5(F,a,u,l,t);
405 const XMLCh Faultactor::LOCAL_NAME[] = UNICODE_LITERAL_10(F,a,u,l,t,a,c,t,o,r);
406 const XMLCh Faultcode::LOCAL_NAME[] = UNICODE_LITERAL_9(F,a,u,l,t,c,o,d,e);
407 const XMLCh Faultstring::LOCAL_NAME[] = UNICODE_LITERAL_11(F,a,u,l,t,s,t,r,i,n,g);
408 const XMLCh Header::LOCAL_NAME[] = UNICODE_LITERAL_6(H,e,a,d,e,r);
409 const XMLCh Header::TYPE_NAME[] = UNICODE_LITERAL_6(H,e,a,d,e,r);
410 const XMLCh Header::ACTOR_ATTRIB_NAME[] = UNICODE_LITERAL_5(a,c,t,o,r);
411 const XMLCh Header::MUSTUNDERSTAND_ATTRIB_NAME[] = UNICODE_LITERAL_14(m,u,s,t,U,n,d,e,r,s,t,a,n,d);