ultimatepp/reference/XmlRpcCall/main.cpp
cxl a05bcac41b .reference: XmlRpcCall fixed
git-svn-id: svn://ultimatepp.org/upp/trunk@3091 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2011-01-25 14:07:48 +00:00

45 lines
905 B
C++

#include <XmlRpc/XmlRpc.h>
using namespace Upp;
struct FoxResult {
bool flerror;
double amount;
String message;
void Map(ValueMapper& m) {
m("flerror", flerror)("amount", amount)("message", message);
}
};
XMLRPC_STRUCT(FoxResult)
#define XRSFILE <XmlRpcCall/FoxRate.xrs>
#include <XmlRpc/xrs.h>
XMLRPC_STRUCT(FoxResult2)
CONSOLE_APP_MAIN
{
FoxResult r;
if(XmlRpcCall("http://foxrate.org/rpc")
.Method("foxrate.currencyConvert")
<< "USD" << "GBP" << 120
>> r)
if(r.flerror)
Cout() << "Server reported error\n";
else
Cout() << r.amount << '\n';
else
Cout() << "Failed.\n";
FoxResult2 r2;
XmlRpcCall foxrate("http://foxrate.org/rpc");
if(foxrate("foxrate.currencyConvert", "GBP", "USD", 130.0) >> r2)
if(r2.flerror)
Cout() << "Server reported error\n";
else
Cout() << r2.amount << '\n';
else
Cout() << "Failed: " << foxrate.GetError() << '\n';
}