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 bool str_;
00044 const SchemaParser* sParser_;
00045 std::vector<std::string> parents_;
00046
00047 };
00048
00049 class WSDLPULL_EXPORT WsdlInvoker
00050 {
00051 public:
00059 WsdlInvoker(const std::string &url);
00060 WsdlInvoker();
00061 ~WsdlInvoker();
00063
00066 bool setWSDLUri(const std::string &url);
00073
00074 bool init(WsdlParser* parser);
00075
00076 int getOperations(std::vector<std::string> & operations);
00077 std::string getOpDocumentaion(const std::string & n);
00083 bool setOperation(const std::string & operation,
00084 WsdlPull::MessageType mType = WsdlPull::Input);
00088 std::string getServiceEndPoint(const std::string & opname) ;
00090
00095 void setMessageType(const WsdlPull::MessageType type);
00096
00099
00110 bool setValue(const std::string & param,void* val);
00111 bool setValue(const std::string & param,void** values,unsigned int occur);
00112 bool setValue(const std::string & param,std::string val);
00113 bool setValue(const std::string & param,std::vector<std::string> values);
00114 bool setValue(const std::vector<std::string> & parents,void* val);
00120 bool invoke(long timeout = 0);
00129 void* getValue(const std::string & param,Schema::Type & t);
00130
00132
00135
00150 int getNextInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum);
00151 int getNextInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum,
00152 std::vector<std::string>& parents);
00158 int getNextHeaderInput(std::string & param ,Schema::Type & type,int & minimum,int & maximum);
00162 int nInputHeaders()const;
00163
00171 bool setInputValue(const int param,void* val);
00172 bool setInputValue(const int id,void** values,unsigned int occur);
00173
00181 bool setInputValue(const int param,std::string val);
00182 bool setInputValue(const int param,std::vector<std::string> values);
00183
00189 bool getNextOutput(std::string & name,TypeContainer * & tc);
00190
00195 TypeContainer* getOutput(const std::string & name);
00196
00202 bool getNextHeaderOutput(std::string & name,TypeContainer*& tc);
00203
00205
00206 void setLocation(const std::string & url);
00207
00208 void setCredentials(const std::string & user, const std::string & pass);
00209 void setProxy(const std::string & host,int port=80);
00210
00211 void setVerbose(bool f);
00212
00213
00214
00215 void printTypeNames(bool f);
00216
00217 std::string errors();
00218
00219 bool status()const;
00220
00221
00222 private:
00223
00224
00225
00226 void serialize();
00227 void serializeType(Schema::Type typeId,
00228 const std::string &tag,
00229 const SchemaParser * sParser,
00230 int minimum,
00231 int maximum,
00232 std::vector<std::string> parents);
00233 void serializeParam(int n,const std::string & tag,
00234 const SchemaParser * sParser);
00235 void serializeContentModel(ContentModel *cm,
00236 const SchemaParser *sParser,
00237 std::vector<std::string> parents);
00242 void post(long timeout=0, std::string username="", std::string passwd="");
00243 void processResults();
00244 void processFault(XmlPullParser* xpp);
00245 void processHeader(XmlPullParser *xpp);
00246 void processBody(const Message* m,XmlPullParser* xpp);
00247 void parseWsdl(const std::string & url);
00248 void serializeHeader();
00249 bool isSoapArray (const ComplexType * ct,const SchemaParser * sParser);
00250
00251 void reset();
00252 void getOperationDetails(const Operation* op);
00253
00254 WsdlParser * wParser_;
00255 WsdlParser * ourParser_;
00256 XmlSerializer * xmlStream_;
00257 Soap* soap_;
00258 const Message* hMessage_;
00259 int hPartId_;
00260 std::ostringstream * soapstr_;
00261 std::ostringstream logger_;
00262 bool status_;
00263 bool serializeMode_;
00264 bool verbose_;
00265 int oHeaders_;
00266 std::map<std::string,const Operation*> opMap_;
00267 const Operation* op_;
00268 Soap::Encoding use_;
00269 std::string encodingStyle_;
00270 Soap::Style style_;
00271 std::string nsp_;
00272 std::string location_;
00273 std::string username_,password_,host_;
00274 int port_;
00275 std::string action_;
00276 std::vector<Parameter> elems_;
00277 std::vector<Parameter> attribs_;
00278 size_t n_;
00279 int iHeaders_;
00280 std::vector<std::pair<std::string,TypeContainer*> > outputs_;
00281 WsdlPull::MessageType messageType_;
00282
00283 };
00284
00285 inline
00286 Parameter::Parameter(Schema::Type t,std::string n,int m,int x,const SchemaParser* s,
00287 const std::vector<std::string>& parents)
00288 :type_(t),
00289 tag_(n),
00290 min_(m),
00291 max_(x),
00292 n_(0),
00293 sParser_(s),
00294 parents_(parents)
00295
00296 {
00297 }
00298
00299 inline
00300 std::string
00301 WsdlInvoker::errors()
00302 {
00303 return logger_.str();
00304 }
00305
00306 inline
00307 bool
00308 WsdlInvoker::setWSDLUri(const std::string &url)
00309 {
00310 parseWsdl(url);
00311 return status_;
00312 }
00313
00314 inline
00315 bool
00316 WsdlInvoker::status()const
00317 {
00318 return status_;
00319 }
00320
00321 inline
00322 void
00323 WsdlInvoker::setLocation(const std::string & url)
00324 {
00325 location_ = url;
00326 }
00327
00328 inline
00329 void
00330 WsdlInvoker::setCredentials(const std::string & user, const std::string & pass)
00331 {
00332 username_ = user;
00333 password_ = pass;
00334 }
00335
00336 inline
00337 void
00338 WsdlInvoker::setProxy(const std::string & host,int port)
00339 {
00340 host_ = host;
00341 port_ = port;
00342 }
00343
00344 inline
00345 void
00346 WsdlInvoker::setVerbose(bool f)
00347 {
00348 verbose_ = f;
00349 }
00350
00351 inline
00352 int
00353 WsdlInvoker::nInputHeaders()const
00354 {
00355 return iHeaders_;
00356 }
00357
00358 inline
00359 void
00360 WsdlInvoker::setMessageType(const WsdlPull::MessageType type)
00361 {
00362 messageType_ = type;
00363 }
00364
00365 }
00366 #endif
00367