I would like to include "named parameters" in the json-rpc 1.1
specification, but mark them as OPTIONAL.
what do you think?
do you want/need "named parameters"?
[ ] I want named parameters
[ ] undecided / I don't need them, but am not against them.
[ ] I don't want named parameters
regards,
Roland
[X] I wanted named parameters, but marked as OPTIONAL.
[ ] I want named parameters
[ ] undecided / I don't need them, but am not against them.
[ ] I don't want named parameters
I can see how they can and will be useful, but I don't particularly
need them any time soon.
I would like to include "named parameters" in the json-rpc 1.1
specification, but mark them as OPTIONAL.
what do you think?
do you want/need "named parameters"?
[X] I want named parameters
[ ] undecided / I don't need them, but am not against them.
[ ] I don't want named parameters
-Jim Washington
Simple Method Description (SMD) is a format for describing a broad range of web services, JSON-RPC being one of them. SMD is used by Dojo for describing web services, and Dustin Machi of Dojo and I have spent a good deal of time last week working on how JSON Schema and SMD could be integrated. I believe SMD and JSON Schema work very well together. SMD has been designed for flexibly describing a variety of web services, and JSON Schema works well to describe the data that is used the by methods in the web services. Together they provide a comprehensive JSON-based representation of web services. SMD has the flexibility of being extremely simple and terse, or it can be very thorough in describing transports, data types, sub-services, and descriptions of these.
I believe that this new SMD (that integrates JSON Schema data typing) would be the best approach for a service description for JSON-RPC. First of all, it is JSON based, JSON-RPC doesn't need to be described in a different format (like XML). Second the new JSON-RPC doesn't need to define it's own service description, but can defer to a service description that is more broadly focused. By using SMD with JSON Schema, JSON-RPC can use a JSON description that can be used by other web services.
Dustin and I do not have a specification ready yet, but I wanted to get our ideas in front of this group through some examples, so we can collaborate and get more feedback on this as we develop this. Dustin has an example of this new SMD at: http://dojotoolkit.org/~dmachi/rpc/ with examples of a variety of web services. For a plain JSON-RPC service, an SMD would look something:
{
transport: "RAW_POST", // see Dustin's example for
more on these properties
envelope:
"JSON-RPC",
serviceUrl: "/service",
methods:
{
add: {
parameters: [
// an array indicates that positional parameters should be used for
this method
{type: "integer", default:
0},
{type: "integer", default:
0},
],
returns:"integer"
},
divide: {
description:"Do division",
parameters: { // an object
indicates that named parameters should be used for this
method
divisor:{type:"integer"},
dividend:{type:"integer"}
},
returns:"float"
},
simpleMethod: {},// almost all
properties are optional, this method description has no requirements on
parameters or return type
getAddress : {
description : "Takes a person and returns an address",
parameters : {
person : {type: // describe this
parameter with a schema
{firstName:{type:"string"},lastName:{type:"string"}}
},
},
returns : // use a schema to
describe the return type
{street:{type:"string"},zip:{type:"string"},state:{type:"string"},town:{type:"string"}}
}
}
}
I made a page for it: http://groups.google.com/group/json-rpc/web/simple-method-description-for-json-rpc-example?hl=en, but it is small, so I just copied it here.
Does this seem like a reasonable approach for a service description for JSON-RPC?
For a little Roland-style voting (thanks for getting that going, Roland)...
[ ] Yes, this has potential to be a recommended service description for JSON-RPC 1.1
[ ] No, we should use ___________ for service description
If so there I believe there are still a number of open questions, and it is still flexible, so I will bring some of the issues to this group if that is allright.
Kris
I would like to include "named parameters" in the json-rpc 1.1
specification, but mark them as OPTIONAL.
what do you think?
do you want/need "named parameters"?
> First of all, it is JSON based
first, I want to note that your example below and the one in V2example.smd
is no valid JSON: Comments are not allowed in JSON, and all names in a
JSON-object must be strings, enclosed in "..".
> {
> transport: "RAW_POST", // see Dustin's example for more on these properties
> envelope: "JSON-RPC",
> serviceUrl: "/service",
question: how would this look like without HTTP?
e.g. if I use raw tcp/ip, i.e. with the address 127.0.0.1, port 12345 ?
or if I use something totally different, i.e. USB or RS232?
would "transport" and "serviceUrl" then be simply omitted?
> methods: {
> add: {
> parameters: [ // an array indicates that positional parameters should be used for this method
> {type: "integer", default: 0},
> {type: "integer", default: 0},
> ],
> returns:"integer"
> },
> divide: {
> description:"Do division",
> parameters: { // an object indicates that named parameters should be used for this method
> divisor:{type:"integer"},
> dividend:{type:"integer"}
> },
> returns:"float"
> },
I think this means that I have to specify a method twice if it can be called
both with named or positional parameters. right?
I would probably prefer 1 definition per method (like in your JSON Schema), and
completely let the user decide if he wants to use named or positional parameters.
example (in valid JSON):
"methods": {
"add": {
"parameters": [
{"type": "integer", "default": 0, "name": "summand1"},
{"type": "integer", "default": 0, "name": "summand2"},
],
"returns": "integer"
},
...
}
where "parameters" is always an array, and "name" may be optional.
> Does this seem like a reasonable approach for a service description for JSON-RPC?
>
> [X] Yes, this has potential to be a recommended service description for JSON-RPC 1.1
yes, if it is not transport-specific (=if it works for every transport I chose).
but because I have not yet played with service-descriptions in real
applications, I cannot tell you more...
regards,
Roland
> e.g. if I use raw tcp/ip, i.e. with the address 127.0.0.1, port 12345 ?
> or if I use something totally different, i.e. USB or RS232?
> would "transport" and "serviceUrl" then be simply omitted?
It seems like transport would be useful for specifying that it is TCP/IP.
Maybe something like:
"transport":"TCP/IP",
"serviceUrl","127.0.0.1:12345",
> I think this means that I have to specify a method twice if it can be
> called
> both with named or positional parameters. right?
>
> I would probably prefer 1 definition per method (like in your JSON
> Schema), and
> completely let the user decide if he wants to use named or positional
> parameters.
> example (in valid JSON):
Certainly some servers will want it one way, and one way only (like all 1.0
servers).
>
> "methods": {
> "add": {
> "parameters": [
> {"type": "integer", "default": 0, "name": "summand1"},
> {"type": "integer", "default": 0, "name": "summand2"},
> ],
> "returns": "integer"
> },
> ...
> }
>
> where "parameters" is always an array, and "name" may be optional.
So if the names are omitted, than one can assume that positional parameters
are required for the defined method? Then servers that can only handle
positional parameters can omit names when they want to indicate that only
positional parameters are allowed for this method. That makes sense, I have
no objections to that. However, will there be servers with methods that only
support named parameters? How will that be indicated?
>> [X] Yes, this has potential to be a recommended service description for
>> JSON-RPC 1.1
> yes, if it is not transport-specific (=if it works for every transport I
> chose).
Definitely, I agree.
> > "methods": {
> > "add": {
> > "parameters": [
> > {"type": "integer", "default": 0, "name": "summand1"},
> > {"type": "integer", "default": 0, "name": "summand2"},
> > ],
> > "returns": "integer"
> > },
> > ...
> > }
> >
> > where "parameters" is always an array, and "name" may be optional.
> So if the names are omitted, than one can assume that positional parameters
> are required for the defined method? Then servers that can only handle
> positional parameters can omit names when they want to indicate that only
> positional parameters are allowed for this method.
that would be possible, but somehow inelegant.
I think it would be better to separate the "methods-definition" from the
"which-invocations-does-the-server-support"-definition.
My spontaneous idea would be:
- use some kind of "server-capabilities-description", which says what
capabilities the server has (e.g. "JSON-RPC 1.1", "Extension foo",
"Extension bar", "only positional parameters", ...)
Since I don't have any experience with service descriptions, I don't
know how this should look like in detail, but I think that other
RPCs may have something like this.
- and method-descriptions, which "only" describe the methods.
regards,
Roland