HAMcast developers

Changes between Version 14 and Version 15 of documentation/tools/monitoring/rest


Ignore:
Timestamp:
02/20/12 17:08:28 (13 years ago)
Author:
Sebastian Meiling
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • documentation/tools/monitoring/rest

    v14 v15  
    22
    33The components of the monitoring framework use a restful web interface to exchange data.
    4 This section is a full documentation of the interface as well as codes examples, showcasing how the interface can be used and extended.
     4This section is a full documentation of the interfaces as well as code examples, showcasing how the interface can be used and extended.
    55
    66== Concept ==
    77
    8 Restful web service is a light weight remote procedure call (rpc) interface, using a client-server architecture.
     8A restful web service is a light weight remote procedure call (rpc) interface, using a client-server architecture.
    99The server provides a number of methods that can be called by the client.
    10 Therefor client and server are connected via TCP using HTTP as message protocol.
     10Therefore client and server are connected via TCP using HTTP as message protocol.
    1111Methods are identified by an URI in the HTTP header.
    12 The payload of a message, the returned value of a method, is encoded in XML.
     12The payload of a message and return values of a method are encoded in XML.
    1313
    14 A detailed description of RESTful web service can be found at : [[BR]]
    15 [http://en.wikipedia.org/wiki/Representational_state_transfer][[BR]]
    16 [http://www.ibm.com/developerworks/webservices/library/ws-restful/]
     14A detailed description of RESTful web service can be found at :
     15 * [http://en.wikipedia.org/wiki/Representational_state_transfer]
     16 * [http://www.ibm.com/developerworks/webservices/library/ws-restful/]
    1717
    18 == Example call ==
     18== Example Call ==
    1919
    20 To call a method on the Rest server a HTTP POST message has to be send to the server.
     20To call a method on a RESTful server a HTTP POST message has to be send.
    2121This POST message has to contain the URL (name of the method) and a number of arguments, if necessary for the call.
    2222
    23 For example, if we want to call the method ''hello_client(int i)'' we use the name of the call as the URL for the HTTP header. The method also takes one argument, in the payload of the HTTP POST we append this argument using a prefix that indicates the order of the arguments.
     23For example, if we want to call the method ''hello_client(int i)''. We use the name of the call as the URL for the HTTP header. The method also takes one argument, in the payload of the HTTP POST we append this argument using a prefix that indicates the order of the arguments.
    2424
    2525{{{
     
    3232}}}
    3333
    34 On every call a response will be created using HTTP REPLY messages and a XML encoded payload. The payload will always start with the name of the call followed by the returned values. There are basically two types of values lists and single values. In case of the ''hello_client'' method the returned value will be a string and a list of numbers counting from 1 to 3.
     34On every call a response will be created using HTTP REPLY messages and a XML encoded payload. The payload will always start with the name of the call followed by the returned values. There are basically two types of values (i) ''lists'' and (ii) ''single values''. In case of {{{hello_client}}} method the returned value will be a string and a list of numbers counting from 1 to 3.
    3535
    3636
     
    6060}}}
    6161
    62 == Example method ==
     62== Example Method ==
    6363
    64 This example will show you how to create a method for the rest interface.
     64This example will show you how to create a method for the RESTful interface.
    6565For this example we add the ''hello_client'' method to the collectors interface.
    66 The function_wrapper.hpp and function_wrapper.cpp are where the method has to be defined and implemented.
     66The function_wrapper.hpp and function_wrapper.cpp are where method has to be defined and implemented.
    6767
    6868We add {{{std::string hello_client(std::vector<std::strings>);}}} to the header file and implement the method.
     
    7171First the number of arguments will be checked, if they don’t match a empty string will be returned. On returning an empty string the caller will create a error message 404 NOT FOUND and send it to the client. This message can be interpreted by the client, that either the method was not found or there are missing/wrong arguments.
    7272After that a XML document is created using boost property tree. The last step is to register this method by calling
    73 {{{register_function("/hello_client",(function_call) &function_wrapper::hello_client);}}}. The first argument of this call defines the URL of the call and the second argument is a function pointer to the method.
     73{{{register_function("/hello_client",(function_call) &function_wrapper::hello_client);}}}. First argument of this call defines is the URL of the call and second argument is a function pointer to the method.
    7474
    7575
     
    107107}}}
    108108
    109 == REST interfaces ==
     109== RESTful Interfaces ==
    110110
    111  * [wiki:documentation/tools/monitoring/rest/daemon Interfaces description of the daemon]
     111 * [wiki:documentation/tools/monitoring/rest/daemon RESTful interface of mdaemon]
    112112
    113  * [wiki:documentation/tools/monitoring/rest/collector Interfaces description of the collector]
     113 * [wiki:documentation/tools/monitoring/rest/collector RESTful interfaces of mcollector]
    114114
    115115