23. Mai 2008

Simple Remote Procedure Call - Response Format

SRPC-Response Format is an extension to SRPC. It specifies a request parameter which selects a response format.
This is primarily intended for the REST variant of SRPC where the SRPC parameters are in the request URI and the result is the response body. Usually, the response body carries a data structure. But it is not clear in which format the data is encoded. A "Format" parameter in the request can select if the response is encoded as XML, JSON, WDDX, etc.

  1. Format=<one of: json, php, wddx, xml, yaml, etc.>

Example:

  1. Format=xml

XML Example: HTTP query:

  1. C: GET /srpc.php?Method=GetPrices&Symbol=GOOG&Date=1969-07-21&Format=xml HTTP/1.1

HTTP response (with a sample XML as a the result value):

  1. S: HTTP/1.1 200 OK
  2. S: Content-type: text/xml
  3. S:
  4. S: <?xml version="1.0"?>
  5. S: <prices>
  6. S: <price time="09:00">121.10</price>
  7. S: <price time="09:05">121.20</price>
  8. S: </prices>

JSON Example: HTTP query:

  1. C: GET /srpc.php?Method=GetPrices&Symbol=GOOG&Date=1969-07-21&Format=json HTTP/1.1

HTTP response (with a sample JSON as the result value):

  1. S: HTTP/1.1 200 OK
  2. S: Content-type: application/json
  3. S:
  4. S: {
  5. S: "prices": [
  6. S: { "time": "09:00", "value": "121.10" },
  7. S: { "time": "09:05", "value": "121.20" }
  8. S: ]
  9. S: }

Keine Kommentare: