30#define PACKAGE_VERSION "1.x"
36 std::cout<<
"Usage wsdl [options] wsdl-uri [operation name] [method parameters] [xpath expression for response]"<<std::endl;
37 std::cout<<
"Version "<<PACKAGE_VERSION<<std::endl;
38 std::cout<<
"Options: "<<std::endl;
39 std::cout<<
" -h Display this message"<<std::endl;
40 std::cout<<
" -x host[:port] Use HTTP proxy on given port"<<std::endl;
41 std::cout<<
" -U user[:password] Specify Proxy authentication"<<std::endl;
42 std::cout<<
" -v Verbose mode,SOAP request and response are logged"<<std::endl;
43 std::cout<<
" -d display WSDL operation's documentation"<<std::endl;
44 std::cout<<
" -p display WSDL port types and their operations"<<std::endl;
45 std::cout<<
" -l list all the WSDL operations "<<std::endl;
46 std::cout<<
" -o Allow setting occurrence constraint (default is 1)"<<std::endl;
47 std::cout<<
" -s Suppress printing type/element names in the output"<<std::endl;
48 std::cout<<
" -t requesttimeout in seconds"<<std::endl;
49 std::cout<<
" -e set SOAP headers in input"<<std::endl;
50 std::cout<<
" -g generate sample SOAP message for the invocation"<<std::endl;
51 std::cout<<
" -w get soap,encoding and wsdl schemas from the web"<<std::endl;
52 std::cout<<
" -f get soap,encoding and wsdl schemas from the filesystem"<<std::endl;
53 std::cout<<
" -r Validate the response message with schema even when xpath selector is used(default is off)"<<std::endl;
54 std::cout<<
"With no arguments,wsdl starts in the interactive mode accepting operation name and parameters from the standard input."<<std::endl<<std::endl;
55 std::cout<<
"An xpath expression can be used to extract elements from web service response.If the expression points to an element or an attribute,the element's text or attribute value will be returned.The expression will match all occurrences in the xml tree"<<std::endl;
71 cout <<
"Port Type :" << p->
getName () <<
" has " <<
81 cout <<
" Input Message:"<<in->
getName()<<endl;
83 cout <<
" Output Message:"<<out->
getName()<<endl;
85 for (MessageList::iterator mli = faults->begin();
89 cout<<
" Fault :"<<(*mli)->getName()<<endl;
107 bool showDoc =
false;
108 bool verbose =
false;
110 bool listops =
false;
111 bool generateSoapMsg =
false;
112 bool accept_password =
false;
113 bool accept_headers =
false;
114 bool processResponse =
false;
122 for (;i<argc && !brkloop;){
126 std::string options(argv[i]+1);
127 char n = options.length();
130 std::string opt(1,options[n]);
138 else if (opt ==
"s"){
143 else if (opt ==
"d"){
148 else if (opt ==
"e"){
150 accept_headers =
true;
153 else if (opt ==
"l"){
158 else if (opt ==
"x"){
160 size_t pos=opt.find(
':');
162 if(pos==std::string::npos){
170 else if (opt ==
"U"){
172 size_t pos=opt.find(
':');
174 if(pos!=std::string::npos)
177 accept_password =
true;
193 else if (opt ==
"g"){
195 generateSoapMsg =
true;
204 timeout=atoi(opt.c_str());
209 processResponse =
true;
211 else if (opt ==
"w"){
215 else if (opt ==
"f"){
220 std::cerr<<
"Unknown option "<<argv[i]<<std::endl;
246 std::cerr<<
"Error processing "<<argv[i]<<std::endl;
247 std::cerr<<invoker.
errors()<<std::endl;
251 std::cerr<<invoker.
errors()<<std::endl;
262 std::cout<<invoker.
errors()<<std::endl;
264 if (i<argc && !listops){
268 std::cerr<<
"Unkown operation name "<<argv[i]<<std::endl;
275 std::vector<std::string> ops;
276 unsigned int choice = 0;
279 for (
size_t s = 0;s<ops.size();s++){
281 std::cout<<s+1<<
"."<<ops[s];
287 std::cout<<
"("<<doc<<
")";
291 if (listops ==
true){
297 std::cout<<
"Choose one of the above operations [1-"<<ops.size()<<
"] :";
299 if (choice>0 && choice<=ops.size())
307 std::cerr<<
"No operation found or missing <binding> section"<<std::endl;
312 std::cerr<<
"Couldn't invoke operation "<<std::endl<<invoker.
errors()<<std::endl;
318 std::cout<<
"Warning:This operation has some SOAP headers in its inputs!(use -e)"<<std::endl;
323 int id =0,minimum,maximum,n;
327 std::vector<std::string> values;
328 std::vector<std::string> parents;
336 accept_headers=
false;
342 id = invoker.
getNextInput(param,t,minimum,maximum,parents);
347 if (occurs && minimum < maximum) {
349 std::cout<<param<<
"["<<minimum<<
","<<maximum<<
"] Enter number of occurrences:";
352 if (n<minimum || n>maximum){
354 std::cerr<<
"Didnt match occurrence constraints"<<std::endl;
363 std::cout<<param<<
": ";
366 values.push_back(val);
370 std::cerr<<
"Incorrect input values "<<std::endl;
382 for (j=0;j<parents.size()-1;j++){
384 std::cout<<parents[j]<<
".";
386 std::cout<<parents[j]<<
": ";
391 std::cerr<<
"Incorrect input value "<<val<<std::endl;
398 if (generateSoapMsg) {
408 std::cerr<<
"libcurl needs to be installed to proceed with invocation"<<std::endl;
409 std::cerr<<
"Try using the -g option to just print the soap message"<<std::endl;
414 if (invoker.
invoke(timeout,(i>=argc || processResponse))){
423 std::vector<std::string> arr=invoker.
getValues<std::string>(argv[i++]);
424 for (
size_t s = 0;s<arr.size();s++)
425 std::cout<<arr[s]<<std::endl;
442 tc->
print(std::cout);
443 std::cout<<std::endl;
448 tc->
print(std::cout);
449 std::cout<<std::endl;
454 cerr<<invoker.
errors()<<std::endl;
455 cerr<<
"Run with -v option and see request.log and response.log"<<endl;
void print(std::ostream &os)
std::vector< Operation * >::const_iterator cOpIterator
bool getOperations(Operation::cOpIterator &start, Operation::cOpIterator &finish) const
int getNumOps(void) const
std::string getName() const
bool setInputValue(const int param, void *val)
int getOperations(std::vector< std::string > &operations)
return names of operations (only for the SOAP binding portType)
bool getNextOutput(std::string &name, TypeContainer *&tc)
bool setWSDLUri(const std::string &url, const std::string &schemaPath="")
void printTypeNames(bool f)
int getNextHeaderInput(std::string ¶m, Schema::Type &type, int &minimum, int &maximum)
std::vector< T > getValues(const std::string &xpath)
sets the param value for an operation by name of the parameter
int getNextInput(std::string ¶m, Schema::Type &type, int &minimum, int &maximum)
bool invoke(long timeout=0, bool processResponse=true)
int nInputHeaders() const
bool getNextHeaderOutput(std::string &name, TypeContainer *&tc)
std::string getOpDocumentation(const std::string &n)
std::string getSoapMessage()
bool setOperation(const std::string &operation, WsdlPull::MessageType mType=WsdlPull::Input)
set the operation to invoke
const PortType * getPortType()
static bool useLocalSchema_
std::list< const Message * > MessageList
bool WSDLPULL_EXPORT getProxy()
std::string WSDLPULL_EXPORT getProxyHost()
void WSDLPULL_EXPORT setProxyPass(const std::string &sProxyPass)
std::string WSDLPULL_EXPORT acceptSecretKey(const std::string &field)
void WSDLPULL_EXPORT setProxy(const bool bProxy)
void WSDLPULL_EXPORT setProxyUser(const std::string &sProxyUser)
void WSDLPULL_EXPORT setProxyHost(const std::string &sProxyHost)
int main(int argc, char *argv[])
bool printPortTypes(std::string uri)