Parameter example

16 views
Skip to first unread message

maku

unread,
Jul 2, 2009, 10:36:16 AM7/2/09
to JSON-RPC
Hi,

I try to use your lib and I have a question about parameter passing.

My approach is: I have an existing class which should be passed to a
service method as single parameter via json e.g.

public class FinderDesc implements Serializable {
private int limit=20;
private int offset=0;
private int totalNumber=-1;
private boolean rowNumberInformationRequired=true;

private List <FinderDataDesc> finderDataList;
....
}

I instantiate the class and use Jackson to get a string representation
(via ObjectMapper -> writeValue):
This leads to (which acts as an example for my json input):
{
"limit":5,
"finderDataList":[
{
"fieldRef":"auditlogEntryType",
"refToFinderDataDescList":null,
"data":"in",
"identifier":"eq"
}
]
,
"totalNumber":-1,
"rowNumberInformationRequired":true,
"rowNumberDeterminationRequired":true,
"moreDataAvailable":false,
"unlimitedResult":false,
"offset":0
}

Now I tried to send a fragment to JsonServiceExporter with this String
(for testing purposes):

{
"id":"0",
"method":"findByDesc",
"params":{
"finderDesc":{
"limit":"5",
"totalNumber":"-1"
}
}
}

A ServiceMethod with the name "findByDesc" exists and is also found by
JsonServiceExporter:

Now the index check takes place (findIndexedMethodAndParams) (returns
in this example to null) -> checks for an array (WHY?)

Now the name check takes place -> (findNamedMethodAndParams) -> this
considers only annotations (WHY?)


Can you tell me what I'm doing wrong?
Which approach would you suggest when you have to pass jsondata which
should be mapped to a single (rather simple) class as parameter.

TIA
Martin

Matt (MPCM)

unread,
Jul 2, 2009, 10:50:14 AM7/2/09
to JSON-RPC
A friendly word,

You may want to take this up directly with the author at the project's
site. Feel free to ask the group, but we represent lots of json-rpc
implementations...

--
Matt (MPCM)

maku

unread,
Jul 3, 2009, 7:18:11 AM7/3/09
to JSON-RPC
Sorry...
I did a mistake. Please forgive me.

Martin

Brian

unread,
Jul 6, 2009, 8:39:18 PM7/6/09
to JSON-RPC

> {
>     "id":"0",
>     "method":"findByDesc",
>     "params":{
>         "finderDesc":{
>             "limit":"5",
>             "totalNumber":"-1"
>         }
>     }
>
> }

This seems wrong, it's missing the "jsonrpc" attribute (which should
be "2.0") ie:
{
"jsonrpc": "2.0",
"id":"0",
"method":"findByDesc",
"params":{
"finderDesc":{
"limit":"5",
"totalNumber":"-1"
}
}
}

What that implies is that you're making a JSON-RPC request with an id
of 0 to the method "findByDesc" with a named parameter of "finderDesc"
which has a limit and totalNumber attribute. Because you're using
named parameters your service interface or (preferably) service
implementation needs to have it's parameters annotated with the name.
This is because there isn't any way of reflecting method parameter
names in java.

You might consider using the indexed parameter approach for your
request:

{
"jsonrpc": "2.0",
"id":"0",
"method":"findByDesc",
"params": [
]
}

Reply all
Reply to author
Forward
0 new messages