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 "AbstractSimpleElement.h"
26 #include "AbstractElementProxy.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;
39 #if defined (_MSC_VER)
40 #pragma warning( push )
41 #pragma warning( disable : 4250 4251 )
46 DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Faultstring);
47 DECL_XMLOBJECTIMPL_SIMPLE(XMLTOOL_DLLLOCAL,Faultactor);
49 class XMLTOOL_DLLLOCAL FaultcodeImpl : public virtual Faultcode,
50 public AbstractSimpleElement,
51 public AbstractDOMCachingXMLObject,
52 public AbstractXMLObjectMarshaller,
53 public AbstractXMLObjectUnmarshaller
57 virtual ~FaultcodeImpl() {
61 FaultcodeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
62 : AbstractXMLObject(nsURI, localName, prefix, schemaType), m_qname(NULL) {
65 FaultcodeImpl(const FaultcodeImpl& src)
66 : AbstractXMLObject(src), AbstractSimpleElement(src), AbstractDOMCachingXMLObject(src), m_qname(NULL) {
67 setCode(src.getCode());
70 QName* getCode() const {
74 void setCode(const QName* qname) {
75 m_qname=prepareForAssignment(m_qname,qname);
77 auto_ptr_XMLCh temp(m_qname->toString().c_str());
78 setTextContent(temp.get());
84 IMPL_XMLOBJECT_CLONE(Faultcode);
87 class XMLTOOL_DLLLOCAL DetailImpl : public virtual Detail,
88 public AbstractElementProxy,
89 public AbstractAttributeExtensibleXMLObject,
90 public AbstractDOMCachingXMLObject,
91 public AbstractXMLObjectMarshaller,
92 public AbstractXMLObjectUnmarshaller
95 virtual ~DetailImpl() {}
97 DetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
98 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
101 DetailImpl(const DetailImpl& src)
102 : AbstractXMLObject(src),
103 AbstractElementProxy(src),
104 AbstractAttributeExtensibleXMLObject(src),
105 AbstractDOMCachingXMLObject(src) {
106 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
108 getXMLObjects().push_back((*i)->clone());
113 IMPL_XMLOBJECT_CLONE(Detail);
116 void marshallAttributes(DOMElement* domElement) const {
117 marshallExtensionAttributes(domElement);
120 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
121 getXMLObjects().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,XMLConstants::SOAP11ENV_NS,false);
187 PROC_TYPED_CHILD(Faultstring,XMLConstants::SOAP11ENV_NS,false);
188 PROC_TYPED_CHILD(Faultactor,XMLConstants::SOAP11ENV_NS,false);
189 PROC_TYPED_CHILD(Detail,XMLConstants::SOAP11ENV_NS,false);
190 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
194 class XMLTOOL_DLLLOCAL BodyImpl : public virtual Body,
195 public AbstractElementProxy,
196 public AbstractAttributeExtensibleXMLObject,
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 AbstractElementProxy(src),
217 AbstractAttributeExtensibleXMLObject(src),
218 AbstractDOMCachingXMLObject(src) {
220 setEncodingStyle(src.getEncodingStyle());
221 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
223 getXMLObjects().push_back((*i)->clone());
228 IMPL_XMLOBJECT_CLONE(Body);
229 IMPL_STRING_ATTRIB(EncodingStyle);
231 void setAttribute(QName& qualifiedName, const XMLCh* value) {
232 if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),XMLConstants::SOAP11ENV_NS)) {
233 if (XMLString::equals(qualifiedName.getLocalPart(),ENCODINGSTYLE_ATTRIB_NAME)) {
234 setEncodingStyle(value);
238 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
242 void marshallAttributes(DOMElement* domElement) const {
243 MARSHALL_STRING_ATTRIB(EncodingStyle,ENCODINGSTYLE,XMLConstants::SOAP11ENV_NS);
244 marshallExtensionAttributes(domElement);
247 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
248 getXMLObjects().push_back(childXMLObject);
251 void processAttribute(const DOMAttr* attribute) {
252 unmarshallExtensionAttribute(attribute);
256 class XMLTOOL_DLLLOCAL HeaderImpl : public virtual Header,
257 public AbstractElementProxy,
258 public AbstractAttributeExtensibleXMLObject,
259 public AbstractDOMCachingXMLObject,
260 public AbstractXMLObjectMarshaller,
261 public AbstractXMLObjectUnmarshaller
265 m_MustUnderstand=XMLConstants::XML_BOOL_NULL;
268 virtual ~HeaderImpl() {
269 XMLString::release(&m_Actor);
272 HeaderImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
273 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
277 HeaderImpl(const HeaderImpl& src)
278 : AbstractXMLObject(src),
279 AbstractElementProxy(src),
280 AbstractAttributeExtensibleXMLObject(src),
281 AbstractDOMCachingXMLObject(src) {
283 setActor(src.getActor());
284 MustUnderstand(m_MustUnderstand);
285 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
287 getXMLObjects().push_back((*i)->clone());
292 IMPL_XMLOBJECT_CLONE(Header);
293 IMPL_STRING_ATTRIB(Actor);
294 IMPL_BOOLEAN_ATTRIB(MustUnderstand);
296 void setAttribute(QName& qualifiedName, const XMLCh* value) {
297 if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),XMLConstants::SOAP11ENV_NS)) {
298 if (XMLString::equals(qualifiedName.getLocalPart(),MUSTUNDERSTAND_ATTRIB_NAME)) {
299 setMustUnderstand(value);
302 else if (XMLString::equals(qualifiedName.getLocalPart(),ACTOR_ATTRIB_NAME)) {
307 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
311 void marshallAttributes(DOMElement* domElement) const {
312 MARSHALL_STRING_ATTRIB(Actor,ACTOR,XMLConstants::SOAP11ENV_NS);
313 MARSHALL_BOOLEAN_ATTRIB(MustUnderstand,MUSTUNDERSTAND,XMLConstants::SOAP11ENV_NS);
314 marshallExtensionAttributes(domElement);
317 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
318 getXMLObjects().push_back(childXMLObject);
321 void processAttribute(const DOMAttr* attribute) {
322 unmarshallExtensionAttribute(attribute);
326 class XMLTOOL_DLLLOCAL EnvelopeImpl : public virtual Envelope,
327 public AbstractAttributeExtensibleXMLObject,
328 public AbstractComplexElement,
329 public AbstractDOMCachingXMLObject,
330 public AbstractXMLObjectMarshaller,
331 public AbstractXMLObjectUnmarshaller
336 m_children.push_back(NULL);
337 m_children.push_back(NULL);
338 m_pos_Header=m_children.begin();
339 m_pos_Body=m_pos_Header;
343 virtual ~EnvelopeImpl() {}
345 EnvelopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
346 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
350 EnvelopeImpl(const EnvelopeImpl& src)
351 : AbstractXMLObject(src), AbstractComplexElement(src),
352 AbstractAttributeExtensibleXMLObject(src), AbstractDOMCachingXMLObject(src) {
355 setHeader(src.getHeader()->cloneHeader());
357 setBody(src.getBody()->cloneBody());
360 IMPL_TYPED_CHILD(Header);
361 IMPL_TYPED_CHILD(Body);
362 IMPL_XMLOBJECT_CLONE(Envelope);
365 void marshallAttributes(DOMElement* domElement) const {
366 marshallExtensionAttributes(domElement);
369 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
370 PROC_TYPED_CHILD(Header,XMLConstants::SOAP11ENV_NS,false);
371 PROC_TYPED_CHILD(Body,XMLConstants::SOAP11ENV_NS,false);
372 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
375 void processAttribute(const DOMAttr* attribute) {
376 unmarshallExtensionAttribute(attribute);
381 #if defined (_MSC_VER)
382 #pragma warning( pop )
385 // Builder Implementations
387 IMPL_XMLOBJECTBUILDER(Body);
388 IMPL_XMLOBJECTBUILDER(Detail);
389 IMPL_XMLOBJECTBUILDER(Envelope);
390 IMPL_XMLOBJECTBUILDER(Fault);
391 IMPL_XMLOBJECTBUILDER(Faultactor);
392 IMPL_XMLOBJECTBUILDER(Faultcode);
393 IMPL_XMLOBJECTBUILDER(Faultstring);
394 IMPL_XMLOBJECTBUILDER(Header);
398 const XMLCh Body::LOCAL_NAME[] = UNICODE_LITERAL_4(B,o,d,y);
399 const XMLCh Body::TYPE_NAME[] = UNICODE_LITERAL_4(B,o,d,y);
400 const XMLCh Body::ENCODINGSTYLE_ATTRIB_NAME[] = UNICODE_LITERAL_13(e,n,c,o,d,i,n,g,S,t,y,l,e);
401 const XMLCh Detail::LOCAL_NAME[] = UNICODE_LITERAL_6(d,e,t,a,i,l);
402 const XMLCh Detail::TYPE_NAME[] = UNICODE_LITERAL_6(d,e,t,a,i,l);
403 const XMLCh Envelope::LOCAL_NAME[] = UNICODE_LITERAL_8(E,n,v,e,l,o,p,e);
404 const XMLCh Envelope::TYPE_NAME[] = UNICODE_LITERAL_8(E,n,v,e,l,o,p,e);
405 const XMLCh Fault::LOCAL_NAME[] = UNICODE_LITERAL_5(F,a,u,l,t);
406 const XMLCh Fault::TYPE_NAME[] = UNICODE_LITERAL_5(F,a,u,l,t);
407 const XMLCh Faultactor::LOCAL_NAME[] = UNICODE_LITERAL_10(F,a,u,l,t,a,c,t,o,r);
408 const XMLCh Faultcode::LOCAL_NAME[] = UNICODE_LITERAL_9(F,a,u,l,t,c,o,d,e);
409 const XMLCh Faultstring::LOCAL_NAME[] = UNICODE_LITERAL_11(F,a,u,l,t,s,t,r,i,n,g);
410 const XMLCh Header::LOCAL_NAME[] = UNICODE_LITERAL_6(H,e,a,d,e,r);
411 const XMLCh Header::TYPE_NAME[] = UNICODE_LITERAL_6(H,e,a,d,e,r);
412 const XMLCh Header::ACTOR_ATTRIB_NAME[] = UNICODE_LITERAL_5(a,c,t,o,r);
413 const XMLCh Header::MUSTUNDERSTAND_ATTRIB_NAME[] = UNICODE_LITERAL_14(m,u,s,t,U,n,d,e,r,s,t,a,n,d);