00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef _SOAPEXTH
00024 #define _SOAPEXTH
00025
00026 #include <iostream>
00027 #include <fstream>
00028
00029 #include <wsdlparser/WsdlExtension.h>
00030 #include <wsdlparser/WsdlParser.h>
00031 #include <schemaparser/SchemaValidator.h>
00032
00033 #if 0
00034 const std::string httpTransport = "http://schemas.xmlsoap.org/soap/http";
00035 const std::string httpBinding = "http://schemas.xmlsoap.org/wsdl/http/";
00036 const std::string soapEncUri = "http://schemas.xmlsoap.org/soap/encoding/";
00037 const std::string soapEnvUri = "http://schemas.xmlsoap.org/soap/envelope/";
00038 const std::string soapBindingUri ="http://schemas.xmlsoap.org/wsdl/soap/";
00039 #endif
00040
00041
00042
00043 class Soap:public WsdlExtension
00044 {
00045 public:
00046
00047 static const std::string httpTransport;
00048 static const std::string httpBinding ;
00049 static const std::string soapEncUri ;
00050 static const std::string soapEnvUri ;
00051 static const std::string soapBindingUri ;
00052
00053 typedef enum
00054 {
00055 LITERAL,
00056 ENCODED
00057 } Encoding;
00058
00059 typedef enum
00060 {
00061 RPC,
00062 DOC
00063 } Style;
00064
00065 typedef enum
00066 {
00067 NONE,
00068 HTTP,
00069 SMTP
00070 } Transport;
00071
00072 Soap();
00073 virtual ~Soap();
00074
00075 Transport getTransportMethod()const;
00076 Style getStyle()const;
00077
00078
00079
00080
00081 std::string getNamespace()const ;
00082 void setNamespacePrefix(string pre);
00083 std::string getNamespacePrefix()const;
00084 bool isNamespaceHandler(const std::string & ns)const;
00085 std::string getExtensibilitySchema(void)const;
00086 std::string getEncodingSchema(void)const ;
00087 void setSchemaParser(SchemaParser * spe);
00088
00089
00090 int handleElement(int parent, XmlPullParser *);
00091
00092 int handleAttribute(int parent, string attName, XmlPullParser *);
00093
00094 int getElementName(int id)const;
00095 int getElemAttribute(int id, int att_num);
00096 int getElemAttributeValue(int id, int att_num);
00097
00098 int getAttributeName(int id)const;
00099
00100
00101 void setStartId(int id);
00102 int getStartId()const;
00103
00104 void setWsdlParser(WsdlParser * wp);
00105 bool wasUsed()const;
00106
00107 void serialize(ostream & out);
00108 void getSoapOperationInfo(int elemId, std::string & soapAction, Soap::Style& style);
00109 void getSoapBodyInfo(int elemId, std::string & ns, Soap::Encoding &use);
00110 void getSoapHeaderInfo(int elemId, int &schemaId, int &typeId);
00111 bool getServiceLocation(int elemId, std::string &location);
00112
00113
00114 bool isSoapBody(int id);
00115 bool isSoapHeader(int id);
00116
00117
00118
00119
00120
00121 private:
00122 void error(string);
00123 int processBinding(TypeContainer * t);
00124 int processOp(int, TypeContainer * t);
00125 int processBody(int, TypeContainer * t);
00126 int processHeader(int, TypeContainer * t);
00127 int processFault(int, TypeContainer * t);
00128 int processAddress(int parent, TypeContainer * t);
00129 std::string sNamespace, sNsPrefix, sTitle;
00130 int startId;
00131 SchemaParser *mySchemaParser;
00132 SchemaValidator *mySchemaValidator;
00133 WsdlParser *wParser;
00134
00135 typedef struct
00136 {
00137 int typeId;
00138 int index;
00139 }IDTableIndex ;
00140
00141 std::vector<IDTableIndex> idTable;
00142 int idCounter;
00143
00144 typedef struct
00145 {
00146 int wsdlOpId;
00147 std::string soapAction;
00148 Style style;
00149 } SoapOperationBinding;
00150 std::vector<SoapOperationBinding> ops_;
00151
00152 typedef struct
00153 {
00154 int messageId;
00155 Encoding use;
00156 int encodingStyle;
00157 std::string urn;
00158 } SoapMessageBinding;
00159 std::vector<SoapMessageBinding> body_;
00160
00161
00162 typedef struct
00163 {
00164 int schema;
00165 int typeId;
00166 }SoapHeaderBinding;
00167 std::vector<SoapHeaderBinding> header_;
00168
00169
00170 Transport transport_;
00171 Style style_;
00172 std::vector<std::string> location_;
00173 };
00174
00175 inline
00176 int
00177 Soap::getElementName(int id)const
00178 {
00179 if (id < startId || id > (startId + idCounter - 1))
00180 return 0;
00181 return idTable[id - startId].typeId;
00182 }
00183
00184
00185 inline
00186 int
00187 Soap::getAttributeName(int id)const
00188 {
00189 if (id < startId || id > (startId + idCounter - 1))
00190 return 0;
00191 return idTable[id - startId].typeId;
00192 }
00193
00194 inline
00195 std::string
00196 Soap::getNamespace()const
00197 {
00198 return sNamespace;
00199 }
00200
00201 inline
00202 void
00203 Soap::setNamespacePrefix(string pre)
00204 {
00205 sNsPrefix = pre;
00206 }
00207
00208 inline
00209 std::string
00210 Soap::getNamespacePrefix()const
00211 {
00212 return sNsPrefix;
00213 }
00214
00215 inline
00216 bool
00217 Soap::isNamespaceHandler(const std::string & ns)const
00218 {
00219 return (ns == sNamespace);
00220 }
00221
00222 inline
00223 void
00224 Soap::setSchemaParser(SchemaParser * spe)
00225 {
00226 mySchemaParser = spe;
00227 mySchemaValidator = new SchemaValidator(mySchemaParser);
00228 }
00229
00230 inline
00231 void
00232 Soap::setStartId(int id)
00233 {
00234 startId = id;
00235 }
00236
00237 inline
00238 int
00239 Soap:: getStartId()const
00240 {
00241 return startId;
00242 }
00243
00244 inline
00245 void
00246 Soap::setWsdlParser(WsdlParser * wp)
00247 {
00248 wParser = wp;
00249 }
00250
00251 inline
00252 bool
00253 Soap::wasUsed()const
00254 {
00255 return (wParser != 0);
00256 }
00257
00258 inline
00259 Soap::Transport
00260 Soap::getTransportMethod()const
00261 {
00262 return transport_;
00263 }
00264
00265 inline
00266 Soap::Style
00267 Soap::getStyle()const
00268 {
00269 return style_;
00270 }
00271
00272 #endif