00001 #ifndef dsSOAP_h
00002 #define dsSOAP_h
00003
00004 #ifdef HAVE_CONFIG_H
00005 # include <config.h>
00006 #endif
00007
00008 #include <dsSmartException.h>
00009 #include <dsutil.h>
00010 #include <dsStrstream.h>
00011
00012 #include <dsDocument.h>
00013
00017 inline std::ostream& SOAPdata(std::ostream& os, char *name, char *value)
00018 {
00019 os << "<" << name << " xsi:type=\"xsd:string\">" << value << "</" << name << ">" << std::endl;
00020 return os;
00021 }
00022
00023 inline std::ostream& SOAPdata(std::ostream& os, char *name, long value)
00024 {
00025 os << "<" << name << " xsi:type=\"xsd:int\">" << value << "</" << name << ">" << std::endl;
00026 return os;
00027 }
00028
00029 inline std::ostream& SOAPdata(std::ostream& os, char *name, double value, int precision = 2)
00030 {
00031 os << "<" << name << " xsi:type=\"xsd:decimal\">" << std::setiosflags(std::ios::fixed) << std::setprecision( precision ) << value << "</" << name << ">" << std::endl;
00032 return os;
00033 }
00034
00035 template <class T>
00036 std::ostream& SOAPdata(std::ostream& os, char *name, T value, char *type)
00037 {
00038 os << "<" << name << " xsi:type=\"" << type << "\">" << value << "</" << name << ">" << std::endl;
00039 return os;
00040 }
00041
00042
00047 inline dsNode *SOAPfault(dsDocument *d)
00048 {
00049 dsNodeList *lst = d->getElementsByTagName("SOAP-ENV:Fault");
00050 return ( lst->empty() ) ? 0 : lst->front();
00051 }
00052
00057 inline dsNode *SOAPbody(dsDocument *d)
00058 {
00059 dsNodeList *lst = d->getElementsByTagName("SOAP-ENV:Body");
00060 return ( lst->empty() ) ? 0 : lst->front();
00061 }
00065 inline char *SOAPfaultcode(dsNode *st)
00066 {
00067 dsDocument *d = st->ownerDocument();
00068 dsNode *n, *txt;
00069 if ( (n = d->findChild("faultcode", st, dsNode::ELEMENT_NODE) ) )
00070 {
00071 if ( (txt = d->textChild(n)) )
00072 return txt->nodeValue();
00073 }
00074
00075 return 0;
00076 }
00077
00081 inline char *SOAPfaultstring(dsNode *st)
00082 {
00083 dsDocument *d = st->ownerDocument();
00084 dsNode *n, *txt;
00085 if ( (n = d->findChild("faultstring", st, dsNode::ELEMENT_NODE) ) )
00086 {
00087 if ( (txt = d->textChild(n)) )
00088 return txt->nodeValue();
00089 }
00090
00091 return 0;
00092 }
00093
00097 inline char *SOAPnodetext(dsNode *st)
00098 {
00099 dsNode *txt;
00100 dsDocument *d = st->ownerDocument();
00101
00102 if ( (txt=d->textChild(st)) )
00103 return txt->nodeValue();
00104 return 0;
00105 }
00106
00112 inline char *SOAPnodetext(char *name, dsNode *start)
00113 {
00114 dsDocument *d = start->ownerDocument();
00115 dsNode *n = d->findChild(name, start, dsNode::ELEMENT_NODE);
00116 return (n) ? SOAPnodetext(n) : 0;
00117 }
00118
00119
00120 #endif