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 "AbstractChildlessElement.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 protected AbstractSimpleElement,
51 public AbstractChildlessElement,
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 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);
86 IMPL_XMLOBJECT_CONTENT;
89 class XMLTOOL_DLLLOCAL DetailImpl : public virtual Detail,
90 public AbstractElementProxy,
91 public AbstractAttributeExtensibleXMLObject,
92 public AbstractDOMCachingXMLObject,
93 public AbstractXMLObjectMarshaller,
94 public AbstractXMLObjectUnmarshaller
97 virtual ~DetailImpl() {}
99 DetailImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
100 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
103 DetailImpl(const DetailImpl& src)
104 : AbstractXMLObject(src),
105 AbstractElementProxy(src),
106 AbstractAttributeExtensibleXMLObject(src),
107 AbstractDOMCachingXMLObject(src) {
108 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
110 getXMLObjects().push_back((*i)->clone());
115 IMPL_XMLOBJECT_CLONE(Detail);
118 void marshallAttributes(DOMElement* domElement) const {
119 marshallExtensionAttributes(domElement);
122 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
123 getXMLObjects().push_back(childXMLObject);
126 void processAttribute(const DOMAttr* attribute) {
127 unmarshallExtensionAttribute(attribute);
131 class XMLTOOL_DLLLOCAL FaultImpl : public virtual Fault,
132 public AbstractComplexElement,
133 public AbstractDOMCachingXMLObject,
134 public AbstractXMLObjectMarshaller,
135 public AbstractXMLObjectUnmarshaller
142 m_children.push_back(NULL);
143 m_children.push_back(NULL);
144 m_children.push_back(NULL);
145 m_children.push_back(NULL);
146 m_pos_Faultcode=m_children.begin();
147 m_pos_Faultstring=m_pos_Faultcode;
149 m_pos_Faultactor=m_pos_Faultstring;
151 m_pos_Detail=m_pos_Faultactor;
160 virtual ~FaultImpl() {}
162 FaultImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
163 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
167 FaultImpl(const FaultImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src) {
169 if (src.getFaultcode())
170 setFaultcode(src.getFaultcode()->cloneFaultcode());
171 if (src.getFaultstring())
172 setFaultstring(src.getFaultstring()->cloneFaultstring());
173 if (src.getFaultactor())
174 setFaultactor(src.getFaultactor()->cloneFaultactor());
176 setDetail(src.getDetail()->cloneDetail());
179 IMPL_XMLOBJECT_CLONE(Fault);
180 IMPL_TYPED_CHILD(Faultcode);
181 IMPL_TYPED_CHILD(Faultstring);
182 IMPL_TYPED_CHILD(Faultactor);
183 IMPL_TYPED_CHILD(Detail);
186 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
187 PROC_TYPED_CHILD(Faultcode,XMLConstants::SOAP11ENV_NS,false);
188 PROC_TYPED_CHILD(Faultstring,XMLConstants::SOAP11ENV_NS,false);
189 PROC_TYPED_CHILD(Faultactor,XMLConstants::SOAP11ENV_NS,false);
190 PROC_TYPED_CHILD(Detail,XMLConstants::SOAP11ENV_NS,false);
191 AbstractXMLObjectUnmarshaller::processChildElement(childXMLObject,root);
195 class XMLTOOL_DLLLOCAL BodyImpl : public virtual Body,
196 public AbstractElementProxy,
197 public AbstractAttributeExtensibleXMLObject,
198 public AbstractDOMCachingXMLObject,
199 public AbstractXMLObjectMarshaller,
200 public AbstractXMLObjectUnmarshaller
203 m_EncodingStyle=NULL;
206 virtual ~BodyImpl() {
207 XMLString::release(&m_EncodingStyle);
210 BodyImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
211 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
215 BodyImpl(const BodyImpl& src)
216 : AbstractXMLObject(src),
217 AbstractElementProxy(src),
218 AbstractAttributeExtensibleXMLObject(src),
219 AbstractDOMCachingXMLObject(src) {
221 setEncodingStyle(src.getEncodingStyle());
222 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
224 getXMLObjects().push_back((*i)->clone());
229 IMPL_XMLOBJECT_CLONE(Body);
230 IMPL_STRING_ATTRIB(EncodingStyle);
232 void setAttribute(QName& qualifiedName, const XMLCh* value) {
233 if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),XMLConstants::SOAP11ENV_NS)) {
234 if (XMLString::equals(qualifiedName.getLocalPart(),ENCODINGSTYLE_ATTRIB_NAME)) {
235 setEncodingStyle(value);
239 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
243 void marshallAttributes(DOMElement* domElement) const {
244 MARSHALL_STRING_ATTRIB(EncodingStyle,ENCODINGSTYLE,XMLConstants::SOAP11ENV_NS);
245 marshallExtensionAttributes(domElement);
248 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
249 getXMLObjects().push_back(childXMLObject);
252 void processAttribute(const DOMAttr* attribute) {
253 unmarshallExtensionAttribute(attribute);
257 class XMLTOOL_DLLLOCAL HeaderImpl : public virtual Header,
258 public AbstractElementProxy,
259 public AbstractAttributeExtensibleXMLObject,
260 public AbstractDOMCachingXMLObject,
261 public AbstractXMLObjectMarshaller,
262 public AbstractXMLObjectUnmarshaller
266 m_MustUnderstand=XMLConstants::XML_BOOL_NULL;
269 virtual ~HeaderImpl() {
270 XMLString::release(&m_Actor);
273 HeaderImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
274 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
278 HeaderImpl(const HeaderImpl& src)
279 : AbstractXMLObject(src),
280 AbstractElementProxy(src),
281 AbstractAttributeExtensibleXMLObject(src),
282 AbstractDOMCachingXMLObject(src) {
284 setActor(src.getActor());
285 MustUnderstand(m_MustUnderstand);
286 for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
288 getXMLObjects().push_back((*i)->clone());
293 IMPL_XMLOBJECT_CLONE(Header);
294 IMPL_STRING_ATTRIB(Actor);
295 IMPL_BOOLEAN_ATTRIB(MustUnderstand);
297 void setAttribute(QName& qualifiedName, const XMLCh* value) {
298 if (qualifiedName.hasNamespaceURI() && XMLString::equals(qualifiedName.getNamespaceURI(),XMLConstants::SOAP11ENV_NS)) {
299 if (XMLString::equals(qualifiedName.getLocalPart(),MUSTUNDERSTAND_ATTRIB_NAME)) {
300 setMustUnderstand(value);
303 else if (XMLString::equals(qualifiedName.getLocalPart(),ACTOR_ATTRIB_NAME)) {
308 AbstractAttributeExtensibleXMLObject::setAttribute(qualifiedName, value);
312 void marshallAttributes(DOMElement* domElement) const {
313 MARSHALL_STRING_ATTRIB(Actor,ACTOR,XMLConstants::SOAP11ENV_NS);
314 MARSHALL_BOOLEAN_ATTRIB(MustUnderstand,MUSTUNDERSTAND,XMLConstants::SOAP11ENV_NS);
315 marshallExtensionAttributes(domElement);
318 void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {
319 getXMLObjects().push_back(childXMLObject);
322 void processAttribute(const DOMAttr* attribute) {
323 unmarshallExtensionAttribute(attribute);
327 class XMLTOOL_DLLLOCAL EnvelopeImpl : public virtual Envelope,
328 public AbstractAttributeExtensibleXMLObject,
329 public AbstractComplexElement,
330 public AbstractDOMCachingXMLObject,
331 public AbstractXMLObjectMarshaller,
332 public AbstractXMLObjectUnmarshaller
337 m_children.push_back(NULL);
338 m_children.push_back(NULL);
339 m_pos_Header=m_children.begin();
340 m_pos_Body=m_pos_Header;
344 virtual ~EnvelopeImpl() {}
346 EnvelopeImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix, const QName* schemaType)
347 : AbstractXMLObject(nsURI, localName, prefix, schemaType) {
351 EnvelopeImpl(const EnvelopeImpl& src)
352 : AbstractXMLObject(src), 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);