00001 #ifndef __ARC_SOAPENVELOP_H__
00002 #define __ARC_SOAPENVELOP_H__
00003
00004 #include <string>
00005
00006 #include <arc/XMLNode.h>
00007
00008 namespace Arc {
00009
00010 class SOAPEnvelope;
00011
00013
00019 class SOAPFault {
00020 friend class SOAPEnvelope;
00021 private:
00022 bool ver12;
00023 XMLNode fault;
00024 XMLNode code;
00025 XMLNode reason;
00026 XMLNode node;
00027 XMLNode role;
00028 XMLNode detail;
00029 public:
00031 typedef enum {
00032 undefined,
00033 unknown,
00034 VersionMismatch,
00035 MustUnderstand,
00036 Sender,
00037 Receiver,
00038 DataEncodingUnknown
00039 } SOAPFaultCode;
00041 SOAPFault(XMLNode body);
00044 SOAPFault(XMLNode body,SOAPFaultCode code,const char* reason);
00047 SOAPFault(XMLNode body,SOAPFaultCode code,const char* reason,bool ver12);
00049 operator bool(void) { return (bool)fault; };
00052 operator XMLNode(void) { return fault; };
00054 SOAPFaultCode Code(void);
00056 void Code(SOAPFaultCode code);
00058 std::string Subcode(int level);
00060 void Subcode(int level,const char* subcode);
00062 std::string Reason(int num = 0);
00064 void Reason(int num,const char* reason);
00066 void Reason(const char* reason) { Reason(0,reason); };
00068 void Reason(const std::string &reason) { Reason(0, reason.c_str()); };
00070 std::string Node(void);
00072 void Node(const char* node);
00074 std::string Role(void);
00076 void Role(const char* role);
00078 XMLNode Detail(bool create = false);
00082 static SOAPEnvelope* MakeSOAPFault(SOAPFaultCode code,const std::string& reason = "");
00083 };
00084
00086
00090 class SOAPEnvelope: public XMLNode {
00091 public:
00092 typedef enum {
00093 Version_1_1,
00094 Version_1_2
00095 } SOAPVersion;
00100 SOAPEnvelope(const std::string& xml);
00102 SOAPEnvelope(const char* xml,int len = -1);
00106 SOAPEnvelope(const NS& ns,bool fault = false);
00109 SOAPEnvelope(XMLNode root);
00111 SOAPEnvelope(const SOAPEnvelope& soap);
00112 ~SOAPEnvelope(void);
00115 SOAPEnvelope* New(void);
00119 void Swap(SOAPEnvelope& soap);
00124 void Swap(Arc::XMLNode& soap);
00132 void Namespaces(const NS& namespaces);
00133 NS Namespaces(void);
00134
00135 void GetXML(std::string& out_xml_str,bool user_friendly = false) const;
00137 XMLNode Header(void) { return header; };
00141 XMLNode Body(void) { return body; };
00143 bool IsFault(void) { return fault != NULL; };
00145 SOAPFault* Fault(void) { return fault; };
00147 SOAPEnvelope& operator=(const SOAPEnvelope& soap);
00148 SOAPVersion Version(void) { return ver12?Version_1_2:Version_1_1; };
00149 protected:
00150 XMLNode envelope;
00151 XMLNode header;
00152 XMLNode body;
00153 private:
00154 bool ver12;
00155 SOAPFault* fault;
00158 void set(void);
00161 void decode(void);
00162 void decode(XMLNode node);
00163 XMLNode findid(XMLNode parent,const std::string& id);
00164 };
00165
00166 }
00167
00168 #endif
00169