#include <XmlRpcClient.h>
Public Member Functions | |
XmlRpcClient (const char *host, int port, const char *uri=0) | |
Construct a client to connect to the server at the specified host:port address. | |
virtual | ~XmlRpcClient () |
Destructor. | |
bool | execute (const char *method, XmlRpcValue const ¶ms, XmlRpcValue &result) |
Execute the named procedure on the remote server. | |
bool | isFault () const |
Returns true if the result of the last execute() was a fault response. | |
virtual void | close () |
Close the connection. | |
virtual unsigned | handleEvent (unsigned eventType) |
Handle server responses. | |
Static Public Attributes | |
static const char | REQUEST_BEGIN [] |
static const char | REQUEST_END_METHODNAME [] = "</methodName>\r\n" |
static const char | PARAMS_TAG [] = "<params>" |
static const char | PARAMS_ETAG [] = "</params>" |
static const char | PARAM_TAG [] = "<param>" |
static const char | PARAM_ETAG [] = "</param>" |
static const char | REQUEST_END [] = "</methodCall>\r\n" |
static const char | METHODRESPONSE_TAG [] = "<methodResponse>" |
static const char | FAULT_TAG [] = "<fault>" |
Protected Types | |
enum | ClientConnectionState { NO_CONNECTION, CONNECTING, WRITE_REQUEST, READ_HEADER, READ_RESPONSE, IDLE } |
Protected Member Functions | |
virtual bool | doConnect () |
virtual bool | setupConnection () |
virtual bool | generateRequest (const char *method, XmlRpcValue const ¶ms) |
virtual std::string | generateHeader (std::string const &body) |
virtual bool | writeRequest () |
virtual bool | readHeader () |
virtual bool | readResponse () |
virtual bool | parseResponse (XmlRpcValue &result) |
Protected Attributes | |
ClientConnectionState | _connectionState |
std::string | _host |
std::string | _uri |
int | _port |
std::string | _request |
std::string | _header |
std::string | _response |
int | _sendAttempts |
int | _bytesWritten |
bool | _executing |
bool | _eof |
bool | _isFault |
int | _contentLength |
XmlRpcDispatch | _disp |
XmlRpcClient::XmlRpcClient | ( | const char * | host, | |
int | port, | |||
const char * | uri = 0 | |||
) |
Construct a client to connect to the server at the specified host:port address.
host | The name of the remote machine hosting the server | |
port | The port on the remote machine where the server is listening | |
uri | An optional string to be sent as the URI in the HTTP GET header |
References XmlRpc::XmlRpcUtil::log(), and XmlRpc::XmlRpcSource::setKeepOpen().
bool XmlRpcClient::execute | ( | const char * | method, | |
XmlRpcValue const & | params, | |||
XmlRpcValue & | result | |||
) |
Execute the named procedure on the remote server.
method | The name of the remote procedure to execute | |
params | An array of the arguments for the method | |
result | The result value to be returned to the client |
References XmlRpc::XmlRpcValue::clear(), XmlRpc::XmlRpcUtil::log(), and XmlRpc::XmlRpcDispatch::work().
unsigned XmlRpcClient::handleEvent | ( | unsigned | eventType | ) | [virtual] |
Handle server responses.
Called by the event dispatcher during execute.
eventType | The type of event that occurred. |
Implements XmlRpc::XmlRpcSource.
References XmlRpc::XmlRpcUtil::error(), XmlRpc::XmlRpcDispatch::Exception, XmlRpc::XmlRpcSocket::getErrorMsg(), XmlRpc::XmlRpcDispatch::ReadableEvent, and XmlRpc::XmlRpcDispatch::WritableEvent.
const char XmlRpcClient::REQUEST_BEGIN [static] |
Initial value:
"<?xml version=\"1.0\"?>\r\n" "<methodCall><methodName>"