XmlRpcClient.h
Go to the documentation of this file.
1 
2 #ifndef _XMLRPCCLIENT_H_
3 #define _XMLRPCCLIENT_H_
4 //
5 // XmlRpc++ Copyright (c) 2002-2003 by Chris Morley
6 //
7 #if defined(_MSC_VER)
8 # pragma warning(disable:4786) // identifier was truncated in debug info
9 #endif
10 
11 
12 #ifndef MAKEDEPEND
13 # include <string>
14 #endif
15 
17 #include "xmlrpcpp/XmlRpcSource.h"
18 #include "xmlrpcpp/XmlRpcDecl.h"
19 
20 namespace XmlRpc {
21 
22  // Arguments and results are represented by XmlRpcValues
23  class XmlRpcValue;
24 
27  public:
28  // Static data
29  static const char REQUEST_BEGIN[];
30  static const char REQUEST_END_METHODNAME[];
31  static const char PARAMS_TAG[];
32  static const char PARAMS_ETAG[];
33  static const char PARAM_TAG[];
34  static const char PARAM_ETAG[];
35  static const char REQUEST_END[];
36  // Result tags
37  static const char METHODRESPONSE_TAG[];
38  static const char FAULT_TAG[];
39 
44  XmlRpcClient(const char* host, int port, const char* uri=0);
45 
47  virtual ~XmlRpcClient();
48 
59  bool execute(const char* method, XmlRpcValue const& params, XmlRpcValue& result);
60 
61  bool executeNonBlock(const char* method, XmlRpcValue const& params);
62  bool executeCheckDone(XmlRpcValue& result);
63 
65  bool isFault() const { return _isFault; }
66 
67 
68  // XmlRpcSource interface implementation
70  virtual void close();
71 
75  virtual unsigned handleEvent(unsigned eventType);
76 
77  protected:
78  // Execution processing helpers
79  virtual bool doConnect();
80  virtual bool setupConnection();
81 
82  virtual bool generateRequest(const char* method, XmlRpcValue const& params);
83  virtual std::string generateHeader(size_t length) const;
84  virtual bool writeRequest();
85  virtual bool readHeader();
86  virtual bool readResponse();
87  virtual bool parseResponse(XmlRpcValue& result);
88 
89  // Possible IO states for the connection
90  enum ClientConnectionState { NO_CONNECTION, CONNECTING, WRITE_REQUEST, READ_HEADER, READ_RESPONSE, IDLE };
92 
93  static const char * connectionStateStr(ClientConnectionState state);
94 
95  // Server location
96  std::string _host;
97  std::string _uri;
98  int _port;
99  public:
100  const std::string &getHost() { return _host; }
101  const std::string &getUri() { return _uri; }
102  int getPort() const { return _port; }
103 
104  // The xml-encoded request, http header of response, and response xml
105  std::string _request;
106  std::string _header;
107  std::string _response;
108 
109  // Number of times the client has attempted to send the request
111 
112  // NOTE(austin): Having multiple variables that imply that the fd is valid
113  // smells funny.
114  // Number of bytes of the request that have been written to the socket so far
116 
117  // True if we are currently executing a request. If you want to multithread,
118  // each thread should have its own client.
120 
121  // True if the server closed the connection
122  bool _eof;
123 
124  // True if a fault response was returned by the server
125  bool _isFault;
126 
127  // Number of bytes expected in the response body (parsed from response header)
129 
130  // Event dispatcher
132 
133  }; // class XmlRpcClient
134 
135 } // namespace XmlRpc
136 
137 #endif // _XMLRPCCLIENT_H_
XmlRpc::XmlRpcClient::_header
std::string _header
Definition: XmlRpcClient.h:106
XmlRpc::XmlRpcClient::_executing
bool _executing
Definition: XmlRpcClient.h:119
XmlRpc::XmlRpcClient::_response
std::string _response
Definition: XmlRpcClient.h:107
XmlRpc::XmlRpcClient::_isFault
bool _isFault
Definition: XmlRpcClient.h:125
XmlRpc::XmlRpcClient::_bytesWritten
int _bytesWritten
Definition: XmlRpcClient.h:115
XmlRpc::XmlRpcClient::getPort
int getPort() const
Definition: XmlRpcClient.h:102
XmlRpc
Definition: XmlRpcClient.h:20
XmlRpc::XmlRpcClient
A class to send XML RPC requests to a server and return the results.
Definition: XmlRpcClient.h:26
XmlRpc::XmlRpcClient::WRITE_REQUEST
@ WRITE_REQUEST
Definition: XmlRpcClient.h:90
XmlRpc::XmlRpcClient::getUri
const std::string & getUri()
Definition: XmlRpcClient.h:101
execute
void execute(XmlRpcValue &params, XmlRpcValue &result)
Definition: HelloServer.cpp:15
XmlRpcDecl.h
XmlRpc::XmlRpcSource
An RPC source represents a file descriptor to monitor.
Definition: XmlRpcSource.h:16
XmlRpcSource.h
XmlRpc::XmlRpcDispatch
Definition: XmlRpcDispatch.h:25
XmlRpc::XmlRpcClient::isFault
bool isFault() const
Returns true if the result of the last execute() was a fault response.
Definition: XmlRpcClient.h:65
XmlRpc::XmlRpcClient::_sendAttempts
int _sendAttempts
Definition: XmlRpcClient.h:110
XmlRpc::XmlRpcClient::ClientConnectionState
ClientConnectionState
Definition: XmlRpcClient.h:90
XmlRpc::XmlRpcClient::getHost
const std::string & getHost()
Definition: XmlRpcClient.h:100
XmlRpc::XmlRpcClient::_uri
std::string _uri
Definition: XmlRpcClient.h:97
XmlRpc::XmlRpcClient::_eof
bool _eof
Definition: XmlRpcClient.h:122
XmlRpc::XmlRpcClient::_request
std::string _request
Definition: XmlRpcClient.h:105
XMLRPCPP_DECL
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:52
XmlRpc::XmlRpcClient::_connectionState
ClientConnectionState _connectionState
Definition: XmlRpcClient.h:91
XmlRpc::XmlRpcClient::_contentLength
int _contentLength
Definition: XmlRpcClient.h:128
XmlRpc::XmlRpcClient::_port
int _port
Definition: XmlRpcClient.h:98
XmlRpc::XmlRpcClient::_disp
XmlRpcDispatch _disp
Definition: XmlRpcClient.h:131
XmlRpc::XmlRpcClient::_host
std::string _host
Definition: XmlRpcClient.h:96
XmlRpc::XmlRpcValue
RPC method arguments and results are represented by Values.
Definition: XmlRpcValue.h:24
XmlRpcDispatch.h


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas , Jacob Perron
autogenerated on Sat Sep 14 2024 02:59:32