A class to send XML RPC requests to a server and return the results. More...
#include <XmlRpcClient.h>
Public Member Functions | |
virtual void | close () |
Close the connection. More... | |
bool | execute (const char *method, XmlRpcValue const ¶ms, XmlRpcValue &result) |
bool | executeCheckDone (XmlRpcValue &result) |
bool | executeNonBlock (const char *method, XmlRpcValue const ¶ms) |
const std::string & | getHost () |
int | getPort () const |
const std::string & | getUri () |
virtual unsigned | handleEvent (unsigned eventType) |
bool | isFault () const |
Returns true if the result of the last execute() was a fault response. More... | |
XmlRpcClient (const char *host, int port, const char *uri=0) | |
virtual | ~XmlRpcClient () |
Destructor. More... | |
Public Member Functions inherited from XmlRpc::XmlRpcSource | |
int | getfd () const |
Return the file descriptor being monitored. More... | |
bool | getKeepOpen () const |
Return whether the file descriptor should be kept open if it is no longer monitored. More... | |
void | setfd (int fd) |
Specify the file descriptor to monitor. More... | |
void | setKeepOpen (bool b=true) |
Specify whether the file descriptor should be kept open if it is no longer monitored. More... | |
XmlRpcSource (int fd=-1, bool deleteOnClose=false) | |
virtual | ~XmlRpcSource () |
Destructor. More... | |
Public Attributes | |
int | _bytesWritten |
int | _contentLength |
XmlRpcDispatch | _disp |
bool | _eof |
bool | _executing |
std::string | _header |
bool | _isFault |
std::string | _request |
std::string | _response |
int | _sendAttempts |
Static Public Attributes | |
static const char | FAULT_TAG [] = "<fault>" |
static const char | METHODRESPONSE_TAG [] = "<methodResponse>" |
static const char | PARAM_ETAG [] = "</param>" |
static const char | PARAM_TAG [] = "<param>" |
static const char | PARAMS_ETAG [] = "</params>" |
static const char | PARAMS_TAG [] = "<params>" |
static const char | REQUEST_BEGIN [] |
static const char | REQUEST_END [] = "</methodCall>\r\n" |
static const char | REQUEST_END_METHODNAME [] = "</methodName>\r\n" |
Protected Types | |
enum | ClientConnectionState { NO_CONNECTION, CONNECTING, WRITE_REQUEST, READ_HEADER, READ_RESPONSE, IDLE } |
Protected Member Functions | |
virtual bool | doConnect () |
virtual std::string | generateHeader (size_t length) const |
virtual bool | generateRequest (const char *method, XmlRpcValue const ¶ms) |
virtual bool | parseResponse (XmlRpcValue &result) |
virtual bool | readHeader () |
virtual bool | readResponse () |
virtual bool | setupConnection () |
virtual bool | writeRequest () |
Static Protected Member Functions | |
static const char * | connectionStateStr (ClientConnectionState state) |
Protected Attributes | |
ClientConnectionState | _connectionState |
std::string | _host |
int | _port |
std::string | _uri |
A class to send XML RPC requests to a server and return the results.
Definition at line 26 of file XmlRpcClient.h.
|
protected |
Enumerator | |
---|---|
NO_CONNECTION | |
CONNECTING | |
WRITE_REQUEST | |
READ_HEADER | |
READ_RESPONSE | |
IDLE |
Definition at line 90 of file XmlRpcClient.h.
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 |
Definition at line 51 of file XmlRpcClient.cpp.
|
virtual |
Destructor.
Definition at line 74 of file XmlRpcClient.cpp.
|
virtual |
Close the connection.
Reimplemented from XmlRpc::XmlRpcSource.
Definition at line 81 of file XmlRpcClient.cpp.
|
staticprotected |
Definition at line 32 of file XmlRpcClient.cpp.
|
protectedvirtual |
Definition at line 250 of file XmlRpcClient.cpp.
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 |
Currently this is a synchronous (blocking) implementation (execute does not return until it receives a response or an error). Use isFault() to determine whether the result is a fault response.
Definition at line 103 of file XmlRpcClient.cpp.
bool XmlRpcClient::executeCheckDone | ( | XmlRpcValue & | result | ) |
Definition at line 168 of file XmlRpcClient.cpp.
bool XmlRpcClient::executeNonBlock | ( | const char * | method, |
XmlRpcValue const & | params | ||
) |
Definition at line 142 of file XmlRpcClient.cpp.
|
protectedvirtual |
Definition at line 320 of file XmlRpcClient.cpp.
|
protectedvirtual |
Definition at line 282 of file XmlRpcClient.cpp.
|
inline |
Definition at line 100 of file XmlRpcClient.h.
|
inline |
Definition at line 102 of file XmlRpcClient.h.
|
inline |
Definition at line 101 of file XmlRpcClient.h.
|
virtual |
Handle server responses. Called by the event dispatcher during execute.
eventType | The type of event that occurred. |
Implements XmlRpc::XmlRpcSource.
Definition at line 194 of file XmlRpcClient.cpp.
|
inline |
Returns true if the result of the last execute() was a fault response.
Definition at line 65 of file XmlRpcClient.h.
|
protectedvirtual |
Definition at line 492 of file XmlRpcClient.cpp.
|
protectedvirtual |
Definition at line 373 of file XmlRpcClient.cpp.
|
protectedvirtual |
Definition at line 453 of file XmlRpcClient.cpp.
|
protectedvirtual |
Definition at line 225 of file XmlRpcClient.cpp.
|
protectedvirtual |
Definition at line 341 of file XmlRpcClient.cpp.
int XmlRpc::XmlRpcClient::_bytesWritten |
Definition at line 115 of file XmlRpcClient.h.
|
protected |
Definition at line 91 of file XmlRpcClient.h.
int XmlRpc::XmlRpcClient::_contentLength |
Definition at line 128 of file XmlRpcClient.h.
XmlRpcDispatch XmlRpc::XmlRpcClient::_disp |
Definition at line 131 of file XmlRpcClient.h.
bool XmlRpc::XmlRpcClient::_eof |
Definition at line 122 of file XmlRpcClient.h.
bool XmlRpc::XmlRpcClient::_executing |
Definition at line 119 of file XmlRpcClient.h.
std::string XmlRpc::XmlRpcClient::_header |
Definition at line 106 of file XmlRpcClient.h.
|
protected |
Definition at line 96 of file XmlRpcClient.h.
bool XmlRpc::XmlRpcClient::_isFault |
Definition at line 125 of file XmlRpcClient.h.
|
protected |
Definition at line 98 of file XmlRpcClient.h.
std::string XmlRpc::XmlRpcClient::_request |
Definition at line 105 of file XmlRpcClient.h.
std::string XmlRpc::XmlRpcClient::_response |
Definition at line 107 of file XmlRpcClient.h.
int XmlRpc::XmlRpcClient::_sendAttempts |
Definition at line 110 of file XmlRpcClient.h.
|
protected |
Definition at line 97 of file XmlRpcClient.h.
|
static |
Definition at line 38 of file XmlRpcClient.h.
|
static |
Definition at line 37 of file XmlRpcClient.h.
|
static |
Definition at line 34 of file XmlRpcClient.h.
|
static |
Definition at line 33 of file XmlRpcClient.h.
|
static |
Definition at line 32 of file XmlRpcClient.h.
|
static |
Definition at line 31 of file XmlRpcClient.h.
|
static |
Definition at line 29 of file XmlRpcClient.h.
|
static |
Definition at line 35 of file XmlRpcClient.h.
|
static |
Definition at line 30 of file XmlRpcClient.h.