ultimatepp/reference/XmlRpcCall/main.cpp
cxl 9fb73d1979 .reference: XmlRpcCall
git-svn-id: svn://ultimatepp.org/upp/trunk@4850 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2012-04-24 09:59:52 +00:00

41 lines
849 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)
CONSOLE_APP_MAIN
{
StdLogSetup(LOG_COUT|LOG_FILE);
XmlRpcRequest xr("http://foxrate.org/rpc");
xr.Method("foxrate.currencyConvert") << "USD" << "GBP" << 120;
Value v = xr.Execute();
if(v.IsError())
LOG("Error: " << v);
else
if(v["flerror"] == 0)
LOG(v["amount"]);
else
LOG("Failed.");
FoxResult r;
if(XmlRpcRequest("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";
}