Saturday, May 28, 2011

SMD service

http://groups.google.com/group/json-schema/web/service-mapping-description-proposal?pli=1

A Service Mapping Description (SMD) is a JSON representation describing web services.


Examples

{
    "transport": "POST",
    "envelope": "URL",
    "target": "/service/",
    "additionalParameters": true,
    "parameters": [
 {
     "name":"outputType",
            "default": "json"
        },
        {
     "name":"ignoreErrors",
            "optional": true
        }
    ],
    "services": {
        "foo": {
            "transport": "GET",
            "target": "executeFoo.php",
            "parameters": [
                {"name":"paramOne", "type": "string"},
                {"name":"paramTwo", "type": "integer", "default": 5},
                {"name":"paramThree", "type": "integer", "optional": true}
            ]
        },
        "add": {
            "transport": "POST",
            "envelope": "JSON-RPC-2.0",
            "additionalParameters": {"type": "integer", "default": 0},
            "parameters": [
                {"type": "integer", "default": 0},
                {"type": "integer", "default": 0}
            ]
        }
    }
}
In the above example, two methods are defined: foo and add. foo is declared to take named parameters, with a service endpoint of /service/executeFoo.php (derived as a relative URL) with url-encoded parameters. The following is an example of a valid service call for the foo method:
GET /service/executeFoo.php?paramOne=value&paramTwo\\0753&outputType=json
The add service is defined to use the service endpoint of /service/ (inherited from the root level), and takes positional parameters using JSON-RPC version 2.0. The following is an example of a valid service call for the add method:
POST /service/

{"id":1,"method":"add","params":[4,7,9]}
Note that all service definition properties are optional. Therefore, a service could be defined:
"simple": {}
and this would indicate that any parameters may be passed in, and return value can be returned.


Type Defined Sub-Services


Examples of Sub-Services

{
   "services":{
       "person": {
            "transport": "REST",
            "envelope": "PATH",
            "target": "person",
            "parameters": [{
                "name":"id",
                "type": "string"
            }],
            "returns": {
                "type": {
                    "id":{"type":"string" },
                    "firstName":{"type":"string"},
                    "lastName":{"type":"string"},
                    "age":{"type":"number","maximum":125,"minimum":0},
                    "address":{"type":"string"}}
                },
                "services":{
         "sendMessage": {
                    "type": "method",
                 "transport": "RAW_POST",
                 "envelope": "JSON-RPC-2.0",
                 "parameters": [
                       {"type": "string", "optional": true},
                       {"type":"object"}],
                 "returns": {"type": "boolean"}
                  }
               }
            }
        }
    }
}

No comments:

Post a Comment