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_
RPC method arguments and results are represented by Values.
Definition: XmlRpcValue.h:24
bool isFault() const
Returns true if the result of the last execute() was a fault response.
Definition: XmlRpcClient.h:65
const std::string & getHost()
Definition: XmlRpcClient.h:100
std::string _request
Definition: XmlRpcClient.h:105
int getPort() const
Definition: XmlRpcClient.h:102
XmlRpcDispatch _disp
Definition: XmlRpcClient.h:131
void execute(XmlRpcValue &params, XmlRpcValue &result)
Definition: HelloServer.cpp:15
ClientConnectionState _connectionState
Definition: XmlRpcClient.h:91
An RPC source represents a file descriptor to monitor.
Definition: XmlRpcSource.h:16
#define XMLRPCPP_DECL
Definition: XmlRpcDecl.h:52
const std::string & getUri()
Definition: XmlRpcClient.h:101
A class to send XML RPC requests to a server and return the results.
Definition: XmlRpcClient.h:26
std::string _response
Definition: XmlRpcClient.h:107


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix
autogenerated on Sun Feb 3 2019 03:29:51