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