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 #include "xmlpull/wsdlpull_export.h"
00033
00034 namespace WsdlPull {
00035
00036
00037
00038 class WSDLPULL_EXPORT Soap:public WsdlExtension
00039 {
00040 public:
00041
00042 static const std::string httpTransport;
00043 static const std::string httpBinding ;
00044 static const std::string soapEncUri11 ;
00045 static const std::string soapEnvUri11 ;
00046 static const std::string soapEncUri12 ;
00047 static const std::string soapEnvUri12 ;
00048 static const std::string soapBindingUri11;
00049 static const std::string soapBindingUri12 ;
00050
00051 typedef enum {
00052 SOAP11,
00053 SOAP12
00054 } SoapVersion;
00055
00056 typedef enum
00057 {
00058 LITERAL,
00059 ENCODED
00060 } Encoding;
00061
00062 typedef enum
00063 {
00064 RPC,
00065 DOC
00066 } Style;
00067
00068 typedef enum
00069 {
00070 NONE,
00071 HTTP,
00072 SMTP
00073 } Transport;
00074
00075 Soap(const std::string & schemaPath = "", SoapVersion a_soapVersion = SOAP11);
00076 virtual ~Soap();
00077
00078
00079
00080
00081 void setSchemaPath(const std::string & schemaPath);
00082
00083 Transport getTransportMethod()const;
00084 Style getStyle()const;
00085
00086
00087
00088
00089 std::string getNamespace()const ;
00090 void setNamespacePrefix(std::string pre);
00091 std::string getNamespacePrefix()const;
00092 bool isNamespaceHandler(const std::string & ns)const;
00093 std::string getExtensibilitySchema(void)const;
00094 std::string getEncodingSchema(void)const ;
00095 std::string getEncodingUri(void) const;
00096 std::string getEnvelopeUri(void) const;
00097 void setSchemaParser(SchemaParser * spe);
00098
00099
00100 int handleElement(int parent, XmlPullParser *);
00101
00102 int handleAttribute(int parent, std::string attName, XmlPullParser *);
00103
00104 int getElementName(int id)const;
00105 int getElemAttribute(int id, int att_num);
00106 int getElemAttributeValue(int id, int att_num);
00107
00108 int getAttributeName(int id)const;
00109
00110
00111 void setStartId(int id);
00112 int getStartId()const;
00113
00114 void setWsdlParser(WsdlParser * wp);
00115 WsdlParser * wsdlParser()const;
00116 bool wasUsed()const;
00117
00118 void serialize(std::ostream & out);
00119 void getSoapOperationInfo(int elemId, std::string & soapAction, Soap::Style& style);
00120 void getSoapBodyInfo(int elemId, std::string &ns, Soap::Encoding &use, std::string &encodingStyle);
00121 void getSoapHeaderInfo(int elemId, std::string &ns, int &partId, const Message* & m);
00122 bool getServiceLocation(int elemId, std::string &location);
00123
00124 SoapVersion getSoapVersion() const { return soapVersion_; }
00125
00126
00127 bool isSoapBody(int id);
00128 bool isSoapHeader(int id);
00129
00130
00131
00132
00133
00134 private:
00135 void error(std::string);
00136 int processBinding(TypeContainer * t);
00137 int processOp(int, TypeContainer * t);
00138 int processBody(int, TypeContainer * t);
00139 int processHeader(int, TypeContainer * t);
00140 int processFault(int, TypeContainer * t);
00141 int processAddress(int parent, TypeContainer * t);
00142 std::string sNamespace, sNsPrefix, sTitle;
00143 int startId;
00144 SchemaParser *mySchemaParser;
00145 SchemaValidator *mySchemaValidator;
00146 WsdlParser *wParser_;
00147
00148 typedef struct
00149 {
00150 int typeId;
00151 int index;
00152 }IDTableIndex ;
00153
00154 std::vector<IDTableIndex> idTable;
00155 int idCounter;
00156
00157 typedef struct
00158 {
00159 int wsdlOpId;
00160 std::string soapAction;
00161 Style style;
00162 } SoapOperationBinding;
00163 std::vector<SoapOperationBinding> ops_;
00164
00165 typedef struct
00166 {
00167 int messageId;
00168 Encoding use;
00169 std::string encodingStyle;
00170 std::string urn;
00171 } SoapMessageBinding;
00172 std::vector<SoapMessageBinding> body_;
00173
00174
00175 typedef struct
00176 {
00177 std::string urn;
00178 int partId_;
00179 const Message* message_;
00180 }SoapHeaderBinding;
00181 std::vector<SoapHeaderBinding> header_;
00182
00183
00184 Transport transport_;
00185 Style style_;
00186 std::vector<std::string> location_;
00187 std::string schemaPath_;
00188
00189 SoapVersion soapVersion_;
00190 };
00191
00192 inline
00193 int
00194 Soap::getElementName(int id)const
00195 {
00196 if (id < startId || id > (startId + idCounter - 1))
00197 return 0;
00198 return idTable[id - startId].typeId;
00199 }
00200
00201
00202 inline
00203 int
00204 Soap::getAttributeName(int id)const
00205 {
00206 if (id < startId || id > (startId + idCounter - 1))
00207 return 0;
00208 return idTable[id - startId].typeId;
00209 }
00210
00211 inline
00212 std::string
00213 Soap::getNamespace()const
00214 {
00215 return sNamespace;
00216 }
00217
00218 inline
00219 void
00220 Soap::setNamespacePrefix(std::string pre)
00221 {
00222 sNsPrefix = pre;
00223 }
00224
00225 inline
00226 std::string
00227 Soap::getNamespacePrefix()const
00228 {
00229 return sNsPrefix;
00230 }
00231
00232 inline
00233 bool
00234 Soap::isNamespaceHandler(const std::string & ns)const
00235 {
00236 return (ns == sNamespace);
00237 }
00238
00239 inline
00240 void
00241 Soap::setSchemaParser(SchemaParser * spe)
00242 {
00243 mySchemaParser = spe;
00244 mySchemaValidator = new SchemaValidator(mySchemaParser);
00245 }
00246
00247 inline
00248 void
00249 Soap::setStartId(int id)
00250 {
00251 startId = id;
00252 }
00253
00254 inline
00255 int
00256 Soap:: getStartId()const
00257 {
00258 return startId;
00259 }
00260
00261 inline
00262 void
00263 Soap::setWsdlParser(WsdlParser * wp)
00264 {
00265 wParser_ = wp;
00266 }
00267
00268 inline
00269 bool
00270 Soap::wasUsed()const
00271 {
00272 return (wParser_ != 0);
00273 }
00274
00275 inline
00276 Soap::Transport
00277 Soap::getTransportMethod()const
00278 {
00279 return transport_;
00280 }
00281
00282 inline
00283 Soap::Style
00284 Soap::getStyle()const
00285 {
00286 return style_;
00287 }
00288
00289 inline
00290 WsdlParser *
00291 Soap::wsdlParser()const
00292 {
00293 return wParser_;
00294 }
00295
00296 }
00297 #endif