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, 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 int partId_;
00163 const Message* message_;
00164 }SoapHeaderBinding;
00165 std::vector<SoapHeaderBinding> header_;
00166
00167
00168 Transport transport_;
00169 Style style_;
00170 std::vector<std::string> location_;
00171 std::string schemaPath_;
00172 };
00173
00174 inline
00175 int
00176 Soap::getElementName(int id)const
00177 {
00178 if (id < startId || id > (startId + idCounter - 1))
00179 return 0;
00180 return idTable[id - startId].typeId;
00181 }
00182
00183
00184 inline
00185 int
00186 Soap::getAttributeName(int id)const
00187 {
00188 if (id < startId || id > (startId + idCounter - 1))
00189 return 0;
00190 return idTable[id - startId].typeId;
00191 }
00192
00193 inline
00194 std::string
00195 Soap::getNamespace()const
00196 {
00197 return sNamespace;
00198 }
00199
00200 inline
00201 void
00202 Soap::setNamespacePrefix(std::string pre)
00203 {
00204 sNsPrefix = pre;
00205 }
00206
00207 inline
00208 std::string
00209 Soap::getNamespacePrefix()const
00210 {
00211 return sNsPrefix;
00212 }
00213
00214 inline
00215 bool
00216 Soap::isNamespaceHandler(const std::string & ns)const
00217 {
00218 return (ns == sNamespace);
00219 }
00220
00221 inline
00222 void
00223 Soap::setSchemaParser(SchemaParser * spe)
00224 {
00225 mySchemaParser = spe;
00226 mySchemaValidator = new SchemaValidator(mySchemaParser);
00227 }
00228
00229 inline
00230 void
00231 Soap::setStartId(int id)
00232 {
00233 startId = id;
00234 }
00235
00236 inline
00237 int
00238 Soap:: getStartId()const
00239 {
00240 return startId;
00241 }
00242
00243 inline
00244 void
00245 Soap::setWsdlParser(WsdlParser * wp)
00246 {
00247 wParser_ = wp;
00248 }
00249
00250 inline
00251 bool
00252 Soap::wasUsed()const
00253 {
00254 return (wParser_ != 0);
00255 }
00256
00257 inline
00258 Soap::Transport
00259 Soap::getTransportMethod()const
00260 {
00261 return transport_;
00262 }
00263
00264 inline
00265 Soap::Style
00266 Soap::getStyle()const
00267 {
00268 return style_;
00269 }
00270
00271 inline
00272 WsdlParser *
00273 Soap::wsdlParser()const
00274 {
00275 return wParser_;
00276 }
00277
00278 }
00279 #endif