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
00029 #ifndef WSDLPULL_EXPORT
00030 #if (defined _MSC_VER) && (defined _MT)
00031 #define WSDLPULL_EXPORT __declspec (dllimport)
00032 #else
00033 #define WSDLPULL_EXPORT
00034 #endif
00035 #endif
00036
00037 namespace WsdlPull{
00038
00039 struct Parameter
00040 {
00041 Parameter(Schema::Type ,std::string,int m,int x,const SchemaParser* s);
00042 Schema::Type type_;
00043 std::string tag_;
00044 unsigned int min_;
00045 unsigned int max_;
00046 int n_;
00047 std::vector<std::string> data_;
00048 bool str_;
00049 const SchemaParser* sParser_;
00050 };
00051
00052 class WSDLPULL_EXPORT WsdlInvoker
00053 {
00054 public:
00062 WsdlInvoker(const std::string &url);
00063 WsdlInvoker();
00064 ~WsdlInvoker();
00066
00069 bool setWSDLUri(const std::string &url);
00076
00077 bool init(WsdlParser* parser);
00078
00079 int getOperations(std::vector<std::string> & operations);
00080 std::string getOpDocumentaion(const std::string & n);
00086 bool setOperation(const std::string & operation);
00088
00091
00102 bool setValue(const std::string & param,void* val);
00103 bool setValue(const std::string & param,void** values,unsigned int occur);
00104 bool setValue(const std::string & param,std::string val);
00105 bool setValue(const std::string & param,std::vector<std::string> values);
00111 bool invoke(long timeout = 0);
00120 void* getValue(const std::string & param,Schema::Type & t);
00121
00123
00126
00140 int getNextInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum);
00146 int getNextHeaderInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum);
00150 int nInputHeaders()const;
00151
00159 bool setInputValue(const int param,void* val);
00160 bool setInputValue(const int id,void** values,unsigned int occur);
00161
00169 bool setInputValue(const int param,std::string val);
00170 bool setInputValue(const int param,std::vector<std::string> values);
00171
00177 bool getNextOutput(std::string & name,TypeContainer * & tc);
00178
00183 TypeContainer* getOutput(const std::string & name);
00184
00190 bool getNextHeaderOutput(std::string & name,TypeContainer*& tc);
00191
00193
00194
00195 void setVerbose(bool f);
00196
00197
00198
00199 void printTypeNames(bool f);
00200
00201 std::string errors();
00202
00203 bool status()const;
00204
00205
00206 private:
00207
00208
00209
00210 void serialize();
00211 void serializeType(Schema::Type typeId,
00212 const std::string &tag,
00213 const SchemaParser * sParser,
00214 int minimum,
00215 int maximum);
00216 void serializeParam(int n,const std::string & tag,
00217 const SchemaParser * sParser);
00218 void serializeContentModel(ContentModel *cm,
00219 const SchemaParser *sParser);
00224 void post(long timeout=0);
00225 void processResults();
00226 void processFault(XmlPullParser* xpp);
00227 void processHeader(XmlPullParser *xpp);
00228 void parseWsdl(const std::string & url);
00229 void serializeHeader();
00230 bool isSoapArray (const ComplexType * ct,const SchemaParser * sParser);
00231
00232 void reset();
00233
00234 WsdlParser * wParser_;
00235 WsdlParser * ourParser_;
00236 XmlSerializer * xmlStream_;
00237 Soap* soap_;
00238 const Message* hMessage_;
00239 int hPartId_;
00240 std::ostringstream * soapstr_;
00241 std::ostringstream logger_;
00242 bool status_;
00243 bool serializeMode_;
00244 bool verbose_;
00245 int oHeaders_;
00246 std::map<std::string,const Operation*> opMap_;
00247 const Operation* op_;
00248 Soap::Encoding use_;
00249 Soap::Style style_;
00250 std::string nsp_;
00251 std::string location_;
00252 std::string action_;
00253 std::vector<Parameter> elems_;
00254 std::vector<Parameter> attribs_;
00255 size_t n_;
00256 int iHeaders_;
00257
00258 std::vector<std::pair<std::string,TypeContainer*> > outputs_;
00259 };
00260
00261 inline
00262 Parameter::Parameter(Schema::Type t,std::string n,int m,int x,const SchemaParser* s)
00263 :type_(t),
00264 tag_(n),
00265 min_(m),
00266 max_(x),
00267 n_(0),
00268 sParser_(s)
00269
00270 {
00271 }
00272
00273 inline
00274 std::string
00275 WsdlInvoker::errors()
00276 {
00277 return logger_.str();
00278 }
00279
00280 inline
00281 bool
00282 WsdlInvoker::setWSDLUri(const std::string &url)
00283 {
00284 parseWsdl(url);
00285 return status_;
00286 }
00287
00288 inline
00289 bool
00290 WsdlInvoker::status()const
00291 {
00292 return status_;
00293 }
00294
00295 inline
00296 void
00297 WsdlInvoker::setVerbose(bool f)
00298 {
00299 verbose_ = f;
00300 }
00301
00302 inline
00303 int
00304 WsdlInvoker::nInputHeaders()const
00305 {
00306 return iHeaders_;
00307 }
00308 }
00309 #endif