ultimatepp/upptst/XmlRpcClient/XmlRpcClient.cpp
cxl d768e2a5b0 .upptst
git-svn-id: svn://ultimatepp.org/upp/trunk@5071 f0d560ea-af0d-0410-9eb7-867de7ffcac7
2012-06-21 07:17:27 +00:00

40 lines
909 B
C++

#include <Core/Core.h>
#include <Core/XmlRpc/XmlRpc.h>
using namespace Upp;
namespace Upp {
extern bool HttpRequest_Trace__;
}
void Compute( double a, Upp::String arithmeticOperator, double b );
int main() {
Time serverTime;
SetDateFormat( "%4d-%02d-%02d" );
XmlRpcRequest call( "127.0.0.1:1234" );
if( call("GetServerTime") >> serverTime ) {
LOG( "Server Time = " << serverTime );
}
else {
LOG( Upp::Format("Error: %s", call.GetError()) );
}
Compute( 12, "+", 12 );
Compute( 12, "*", 12 );
Compute( 12, "+56", 12 );
Compute( 12, "/", 0 );
return 0;
}
void Compute( double a, Upp::String arithmeticOperator, double b ) {
double result = 0;
XmlRpcRequest call( "127.0.0.1:1234" );
if( call("Compute", a, arithmeticOperator, b) >> result ) {
LOG( Upp::Format("%f %s %f = %f", a, arithmeticOperator, b, result) );
}
else {
LOG( Upp::Format("Error: %s", call.GetError()) );
}
}