ultimatepp/reference/XmlRpcCall/main.cpp
cxl 6ce0c40405 .reference: XmlRpc
git-svn-id: svn://ultimatepp.org/upp/trunk@4890 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2012-05-01 14:59:33 +00:00

41 lines
780 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)
LOG("Server reported erro");
else
LOG(r.amount);
else
LOG("Failed.");
}