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