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 class WSDLPULL_EXPORT Soap:public WsdlExtension
00036 {
00037 public:
00038
00039 static const std::string httpTransport;
00040 static const std::string httpBinding ;
00041 static const std::string soapEncUri ;
00042 static const std::string soapEnvUri ;
00043 static const std::string soapBindingUri ;
00044
00045 typedef enum
00046 {
00047 LITERAL,
00048 ENCODED
00049 } Encoding;
00050
00051 typedef enum
00052 {
00053 RPC,
00054 DOC
00055 } Style;
00056
00057 typedef enum
00058 {
00059 NONE,
00060 HTTP,
00061 SMTP
00062 } Transport;
00063
00064 Soap(const std::string & schemaPath = "");
00065 virtual ~Soap();
00066
00067
00068
00069
00070 void setSchemaPath(const std::string & schemaPath);
00071
00072 Transport getTransportMethod()const;
00073 Style getStyle()const;
00074
00075
00076
00077
00078 std::string getNamespace()const ;
00079 void setNamespacePrefix(std::string pre);
00080 std::string getNamespacePrefix()const;
00081 bool isNamespaceHandler(const std::string & ns)const;
00082 std::string getExtensibilitySchema(void)const;
00083 std::string getEncodingSchema(void)const ;
00084 void setSchemaParser(SchemaParser * spe);
00085
00086
00087 int handleElement(int parent, XmlPullParser *);
00088
00089 int handleAttribute(int parent, std::string attName, XmlPullParser *);
00090
00091 int getElementName(int id)const;
00092 int getElemAttribute(int id, int att_num);
00093 int getElemAttributeValue(int id, int att_num);
00094
00095 int getAttributeName(int id)const;
00096
00097
00098 void setStartId(int id);
00099 int getStartId()const;
00100
00101 void setWsdlParser(WsdlParser * wp);
00102 WsdlParser * wsdlParser()const;
00103 bool wasUsed()const;
00104
00105 void serialize(std::ostream & out);
00106 void getSoapOperationInfo(int elemId, std::string & soapAction, Soap::Style& style);
00107 void getSoapBodyInfo(int elemId, std::string &ns, Soap::Encoding &use, std::string &encodingStyle);
00108 void getSoapHeaderInfo(int elemId, std::string &ns, int &partId, const Message* & m);
00109 bool getServiceLocation(int elemId, std::string &location);
00110
00111
00112 bool isSoapBody(int id);
00113 bool isSoapHeader(int id);
00114
00115
00116
00117
00118
00119 private:
00120 void error(std::string);
00121 int processBinding(TypeContainer * t);
00122 int processOp(int, TypeContainer * t);
00123 int processBody(int, TypeContainer * t);
00124 int processHeader(int, TypeContainer * t);
00125 int processFault(int, TypeContainer * t);
00126 int processAddress(int parent, TypeContainer * t);
00127 std::string sNamespace, sNsPrefix, sTitle;
00128 int startId;
00129 SchemaParser *mySchemaParser;
00130 SchemaValidator *mySchemaValidator;
00131 WsdlParser *wParser_;
00132
00133 typedef struct
00134 {
00135 int typeId;
00136 int index;
00137 }IDTableIndex ;
00138
00139 std::vector<IDTableIndex> idTable;
00140 int idCounter;
00141
00142 typedef struct
00143 {
00144 int wsdlOpId;
00145 std::string soapAction;
00146 Style style;
00147 } SoapOperationBinding;
00148 std::vector<SoapOperationBinding> ops_;
00149
00150 typedef struct
00151 {
00152 int messageId;
00153 Encoding use;
00154 std::string encodingStyle;
00155 std::string urn;
00156 } SoapMessageBinding;
00157 std::vector<SoapMessageBinding> body_;
00158
00159
00160 typedef struct
00161 {
00162 std::string urn;
00163 int partId_;
00164 const Message* message_;
00165 }SoapHeaderBinding;
00166 std::vector<SoapHeaderBinding> header_;
00167
00168
00169 Transport transport_;
00170 Style style_;
00171 std::vector<std::string> location_;
00172 std::string schemaPath_;
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(std::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 inline
00273 WsdlParser *
00274 Soap::wsdlParser()const
00275 {
00276 return wParser_;
00277 }
00278
00279 }
00280 #endif