1/* 2 xml-rpc-weblogs.cpp 3 4 XML-RPC weblogUpdates.ping example in C++ 5 6 See http://xmlrpc.scripting.com/weblogsCom for more details. 7 8 Requires xml-rpc.h and xml-rpc.cpp 9 10 Compile: 11 soapcpp2 xml-rpc.h 12 cc xml-rpc-weblogs.cpp xml-rpc.cpp xml-rpc-io.cpp stdsoap2.cpp soapC.cpp 13 14-------------------------------------------------------------------------------- 15gSOAP XML Web services tools 16Copyright (C) 2001-2008, Robert van Engelen, Genivia, Inc. All Rights Reserved. 17This software is released under one of the following two licenses: 18GPL or Genivia's license for commercial use. 19-------------------------------------------------------------------------------- 20GPL license. 21 22This program is free software; you can redistribute it and/or modify it under 23the terms of the GNU General Public License as published by the Free Software 24Foundation; either version 2 of the License, or (at your option) any later 25version. 26 27This program is distributed in the hope that it will be useful, but WITHOUT ANY 28WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 29PARTICULAR PURPOSE. See the GNU General Public License for more details. 30 31You should have received a copy of the GNU General Public License along with 32this program; if not, write to the Free Software Foundation, Inc., 59 Temple 33Place, Suite 330, Boston, MA 02111-1307 USA 34 35Author contact information: 36engelen@genivia.com / engelen@acm.org 37-------------------------------------------------------------------------------- 38A commercial use license is available from Genivia, Inc., contact@genivia.com 39-------------------------------------------------------------------------------- 40*/ 41 42#include "soapH.h" 43#include "xml-rpc-io.h" 44 45using namespace std; 46 47#define ENDPOINT "http://rpc.weblogs.com/RPC2" 48 49int main() 50{ 51 soap *ctx = soap_new(); 52 // define the weblogsUpdates.ping method 53 methodCall ping(ctx, ENDPOINT, "weblogsUpdates.ping"); 54 // set the two parameters of the method 55 ping[0] = "Scripting News"; 56 ping[1] = "http://www.scripting.com/"; 57 // make the call 58 params output = ping(); 59 // error? 60 if (ping.error()) 61 soap_print_fault(ctx, stderr); 62 else if (output.empty()) 63 cout << ping.fault() << endl; 64 else 65 { if (output[0].is_struct()) 66 { if (output[0]["flerror"].is_false()) 67 cout << "Success: "; 68 else 69 cout << "Failure: "; 70 cout << output[0]["message"] << endl; 71 } 72 else 73 cout << "Message format error:" << endl << output[0] << endl; 74 } 75 // delete all data 76 soap_destroy(ctx); 77 soap_end(ctx); 78 // free context 79 soap_free(ctx); 80 return 0; 81} 82 83/* Don't need a namespace table. We put an empty one here to avoid link errors */ 84struct Namespace namespaces[] = { {NULL, NULL} }; 85