XmlRpc++: XmlRpc::XmlRpcClient Class Reference

# XmlRpc::XmlRpcClient Class Reference

A class to send XML RPC requests to a server and return the results. More...

`#include <XmlRpcClient.h>`

Inheritance diagram for XmlRpc::XmlRpcClient:

List of all members.

## 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 &params, 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 &params)
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

## Detailed Description

A class to send XML RPC requests to a server and return the results.

## Constructor & Destructor Documentation

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.

Parameters:

  | 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().

## Member Function Documentation

bool XmlRpcClient::execute | ( | const char * | method,
|  | XmlRpcValue const & | params,
|  | XmlRpcValue & | result |
| ) |  |  |

Execute the named procedure on the remote server.

Parameters:

  | 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

Returns:
  true if the request was sent and a result received (although the result might be a fault).

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.

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.

Parameters:

  | eventType | The type of event that occurred.

See also:
  XmlRpcDispatch::EventType

Implements XmlRpc::XmlRpcSource.

References XmlRpc::XmlRpcUtil::error(), XmlRpc::XmlRpcDispatch::Exception, XmlRpc::XmlRpcSocket::getErrorMsg(), XmlRpc::XmlRpcDispatch::ReadableEvent, and XmlRpc::XmlRpcDispatch::WritableEvent.

## Member Data Documentation

const char XmlRpcClient::REQUEST_BEGIN`[static]`

Initial value:

      "<?xml version=\"1.0\"?>\r\n"
      "<methodCall><methodName>"

The documentation for this class was generated from the following files:

- XmlRpcClient.h
- XmlRpcClient.cpp