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 struct Parameter
00030 {
00031 Parameter(Schema::Type ,std::string,int m,int x,const SchemaParser* s);
00032 Schema::Type type_;
00033 std::string tag_;
00034 unsigned int min_;
00035 unsigned int max_;
00036 int n_;
00037 std::vector<std::string> data_;
00038 bool str_;
00039 const SchemaParser* sParser_;
00040 };
00041
00042 class WsdlInvoker
00043 {
00044 public:
00052 WsdlInvoker(const std::string &url);
00053 WsdlInvoker();
00054 ~WsdlInvoker();
00056
00059 bool setWSDLUri(const std::string &url);
00065 int getOperations(std::vector<std::string> & operations);
00066 std::string getOpDocumentaion(const std::string & n);
00072 bool setOperation(const std::string & operation);
00074
00077
00088 bool setValue(const std::string & param,void* val);
00089 bool setValue(const std::string & param,void** values,unsigned int occur);
00090 bool setValue(const std::string & param,std::string val);
00091 bool setValue(const std::string & param,std::vector<std::string> values);
00096 bool invoke();
00105 void* getValue(const std::string & param,Schema::Type & t);
00106
00108
00111
00125 int getNextInput(std::string & param ,Schema::Type & type,int & min,int & max);
00126
00134 bool setInputValue(const int param,void* val);
00135 bool setInputValue(const int id,void** values,unsigned int occur);
00136
00144 bool setInputValue(const int param,std::string val);
00145 bool setInputValue(const int param,std::vector<std::string> values);
00149 bool getNextOutput(std::string & name,TypeContainer * & tc);
00154 TypeContainer* getOutput(const std::string & name);
00155
00157
00158
00159 void setVerbose(bool f);
00160
00161
00162 std::string errors();
00163
00164 bool status()const;
00165
00166
00167 private:
00168
00169
00170
00171 void serialize();
00172 void serializeType(Schema::Type typeId,
00173 const std::string &tag,
00174 const SchemaParser * sParser,
00175 int min,
00176 int max);
00177 void serializeParam(int n,const std::string & tag,
00178 const SchemaParser * sParser);
00179 void serializeContentModel(ContentModel *cm,
00180 const SchemaParser *sParser);
00181
00182 void post();
00183 void processResults();
00184 void parseWsdl(const std::string & url);
00185
00186 void reset();
00187
00188 WsdlParser * wParser_;
00189 XmlSerializer * xmlStream_;
00190 std::ostringstream * soapstr_;
00191 std::ostringstream logger_;
00192 bool status_;
00193 bool serializeMode_;
00194 bool verbose_;
00195 std::map<std::string,const Operation*> opMap_;
00196 const Operation* op_;
00197 Soap::Encoding use_;
00198 Soap::Style style_;
00199 std::string nsp_;
00200 std::string location_;
00201 std::string action_;
00202 std::vector<Parameter> elems_;
00203 std::vector<Parameter> attribs_;
00204 size_t n_;
00205 std::vector<std::pair<std::string,TypeContainer*> > outputs_;
00206 };
00207
00208 inline
00209 Parameter::Parameter(Schema::Type t,std::string n,int m,int x,const SchemaParser* s)
00210 :type_(t),
00211 tag_(n),
00212 min_(m),
00213 max_(x),
00214 n_(0),
00215 sParser_(s)
00216
00217 {
00218 }
00219
00220 inline
00221 std::string
00222 WsdlInvoker::errors()
00223 {
00224 return logger_.str();
00225 }
00226
00227 inline
00228 bool
00229 WsdlInvoker::setWSDLUri(const std::string &url)
00230 {
00231 parseWsdl(url);
00232 return status_;
00233 }
00234
00235 inline
00236 bool
00237 WsdlInvoker::status()const
00238 {
00239 return status_;
00240 }
00241
00242 inline
00243 void
00244 WsdlInvoker::setVerbose(bool f)
00245 {
00246 verbose_ = f;
00247 }
00248 #endif