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(std::string const& body);
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  // Server location
94  std::string _host;
95  std::string _uri;
96  int _port;
97  public:
98  const std::string &getHost() { return _host; }
99  const std::string &getUri() { return _uri; }
100  int getPort() const { return _port; }
101 
102  // The xml-encoded request, http header of response, and response xml
103  std::string _request;
104  std::string _header;
105  std::string _response;
106 
107  // Number of times the client has attempted to send the request
109 
110  // Number of bytes of the request that have been written to the socket so far
112 
113  // True if we are currently executing a request. If you want to multithread,
114  // each thread should have its own client.
116 
117  // True if the server closed the connection
118  bool _eof;
119 
120  // True if a fault response was returned by the server
121  bool _isFault;
122 
123  // Number of bytes expected in the response body (parsed from response header)
125 
126  // Event dispatcher
128 
129  }; // class XmlRpcClient
130 
131 } // namespace XmlRpc
132 
133 #endif // _XMLRPCCLIENT_H_
Definition: XmlRpc.h:39
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:98
std::string _request
Definition: XmlRpcClient.h:103
int getPort() const
Definition: XmlRpcClient.h:100
XmlRpcDispatch _disp
Definition: XmlRpcClient.h:127
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:99
A class to send XML RPC requests to a server and return the results.
Definition: XmlRpcClient.h:26
std::string _response
Definition: XmlRpcClient.h:105


xmlrpcpp
Author(s): Chris Morley, Konstantin Pilipchuk, Morgan Quigley, Austin Hendrix, Dirk Thomas
autogenerated on Mon Nov 2 2020 03:52:24