00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _WSDLINVOKERH
00023 #define _WSDLINVOKERH
00024
00025 #include "xmlpull/XmlSerializer.h"
00026 #include "wsdlparser/WsdlParser.h"
00027 #include "wsdlparser/Soap.h"
00028 #include "xmlpull/wsdlpull_export.h"
00029
00030
00031 namespace WsdlPull{
00032
00033 struct Parameter
00034 {
00035 Parameter(Schema::Type ,std::string,int m,int x,const SchemaParser* s,
00036 const std::vector<std::string>& parents);
00037 Schema::Type type_;
00038 std::string tag_;
00039 unsigned int min_;
00040 unsigned int max_;
00041 int n_;
00042 std::vector<std::string> data_;
00043
00044 const SchemaParser* sParser_;
00045 std::vector<std::string> parents_;
00046
00047 };
00048
00049 class WSDLPULL_EXPORT WsdlInvoker
00050 {
00051 public:
00052
00053
00054
00055
00056
00057
00058
00059 WsdlInvoker(const std::string &url);
00060 WsdlInvoker(const std::string &url, const std::string &schemaPath);
00061 WsdlInvoker();
00062 ~WsdlInvoker();
00063
00064
00065
00066
00067 bool setWSDLUri(const std::string &url);
00068
00069
00070
00071
00072
00073
00074
00075 bool init(WsdlParser* parser);
00076
00077 int getOperations(std::vector<std::string> & operations);
00078 std::string getOpDocumentation(const std::string & n);
00079 std::string getDocumentation();
00080
00081
00082
00083
00084
00085 bool setOperation(const std::string & operation,
00086 WsdlPull::MessageType mType = WsdlPull::Input);
00087
00088
00089
00090 std::string getServiceEndPoint(const std::string & opname) ;
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107 bool setValue(const std::string & param,void* val);
00108 bool setValue(const std::string & param,void** values,unsigned int occur);
00109 bool setValue(const std::string & param,std::string val);
00110 bool setValue(const std::string & param,std::vector<std::string> values);
00111 bool setValue(const std::vector<std::string> & parents,void* val);
00112
00113
00114
00115
00116
00117 bool invoke(long timeout = 0);
00118
00119
00120
00121
00122
00123
00124
00125
00126 void* getValue(const std::string & param,Schema::Type & t);
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147 int getNextInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum);
00148 int getNextInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum,
00149 std::vector<std::string>& parents);
00150
00151
00152
00153
00154
00155 int getNextHeaderInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum);
00156 int getNextHeaderInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum,
00157 std::vector<std::string>& parents);
00158
00159
00160
00161 int nInputHeaders()const;
00162
00163
00164
00165
00166
00167
00168
00169
00170 bool setInputValue(const int param,void* val);
00171 bool setInputValue(const int id,void** values,unsigned int occur);
00172
00173
00174
00175
00176
00177
00178
00179
00180 bool setInputValue(const int param,std::string val);
00181 bool setInputValue(const int param,std::vector<std::string> values);
00182
00183
00184
00185
00186
00187
00188 bool getNextOutput(std::string & name,TypeContainer * & tc);
00189
00190
00191
00192
00193
00194 TypeContainer* getOutput(const std::string & name);
00195
00196
00197
00198
00199
00200
00201 bool getNextHeaderOutput(std::string & name,TypeContainer*& tc);
00202
00203
00204
00205 void setLocation(const std::string & url);
00206
00207 void setCredentials(const std::string & user, const std::string & pass);
00208
00209 std::string getSoapMessage();
00210
00211 void setProxy(const std::string & host,int port=80);
00212
00213 void setVerbose(bool f);
00214
00215
00216
00217 void printTypeNames(bool f);
00218
00219 std::string errors();
00220
00221 bool status()const;
00222
00223
00224 private:
00225
00226
00227
00228 void serialize();
00229 void serializeType(Schema::Type typeId,
00230 const std::string &tag,
00231 const SchemaParser * sParser,
00232 int minimum,
00233 int maximum,
00234 std::vector<std::string> parents,
00235 const std::string nsp="",
00236 bool isRoot = false);
00237
00238 void serializeParam(int n,const std::string & tag,
00239 const SchemaParser * sParser,
00240 const std::string nsp="",
00241 bool isRoot = false);
00242 void serializeContentModel(ContentModel *cm,
00243 const SchemaParser *sParser,
00244 std::vector<std::string> parents);
00245
00246
00247
00248
00249 void post(long timeout=0, std::string username="", std::string passwd="");
00250 void processResults();
00251 void processFault(XmlPullParser* xpp);
00252 void processHeader(XmlPullParser *xpp);
00253 void processBody(const Message* m,XmlPullParser* xpp);
00254 void parseWsdl(const std::string & url, const std::string & schemaPath = "");
00255 void serializeHeader();
00256 bool isSoapArray (const ComplexType * ct,const SchemaParser * sParser);
00257
00258 void reset();
00259 void getOperationDetails(const Operation* op);
00260 std::string getPrefix(const std::string& nsp);
00261
00262 WsdlParser * wParser_;
00263 WsdlParser * ourParser_;
00264 XmlSerializer * xmlStream_;
00265 Soap* soap_;
00266 bool soapheaders_;
00267 int hPartId_;
00268 std::string hnsp_;
00269 std::ostringstream * soapstr_;
00270 std::ostringstream logger_;
00271 bool status_;
00272 bool serializeMode_;
00273 bool verbose_;
00274 bool dontPost_;
00275 int oHeaders_;
00276 std::map<std::string,const Operation*> opMap_;
00277 const Operation* op_;
00278 Soap::Encoding use_;
00279 std::string encodingStyle_;
00280 Soap::Style style_;
00281 std::string nsp_;
00282 std::string location_;
00283 std::string username_,password_,host_;
00284 int port_;
00285 std::string action_;
00286 std::vector<Parameter> elems_;
00287 size_t n_;
00288 int iHeaders_;
00289 std::vector<std::pair<std::string,TypeContainer*> > outputs_;
00290 WsdlPull::MessageType messageType_;
00291
00292 std::vector<std::string> prefixes_;
00293
00294 };
00295
00296 inline
00297 Parameter::Parameter(Schema::Type t,std::string n,int m,int x,const SchemaParser* s,
00298 const std::vector<std::string>& parents)
00299 :type_(t),
00300 tag_(n),
00301 min_(m),
00302 max_(x),
00303 n_(0),
00304 sParser_(s),
00305 parents_(parents)
00306
00307 {
00308 }
00309
00310 inline
00311 std::string
00312 WsdlInvoker::errors()
00313 {
00314 return logger_.str();
00315 }
00316
00317 inline
00318 bool
00319 WsdlInvoker::setWSDLUri(const std::string &url)
00320 {
00321 parseWsdl(url);
00322 return status_;
00323 }
00324
00325 inline
00326 bool
00327 WsdlInvoker::status()const
00328 {
00329 return status_;
00330 }
00331
00332 inline
00333 void
00334 WsdlInvoker::setLocation(const std::string & url)
00335 {
00336 location_ = url;
00337 }
00338
00339 inline
00340 void
00341 WsdlInvoker::setVerbose(bool f)
00342 {
00343 verbose_ = f;
00344 }
00345
00346 inline
00347 int
00348 WsdlInvoker::nInputHeaders()const
00349 {
00350 return iHeaders_;
00351 }
00352
00353
00354 }
00355 #endif