Named param(@JsonRpcParam) does not work.
saintping opened this issue · 2 comments
I Write a simple “hello wolrd“ program like example showed at https://github.com/briandilley/jsonrpc4j/wiki/JSON-RPC-for-Java-Client-&-Spring-Boot-(Server-example).
My project environment is Spring boot 2.1.0 + Jsonrpc4j 1.5.3, run in JVM 1.8.0. It's work ok under "indexed param" pattern.
$ curl -H "Content-Type: application/json" -d '{"id":"1","jsonrpc":"2.0","method ":"hello","params":["matthew"]}' http://localhost:8080/test/jsonrpc
{"jsonrpc":"2.0","id":"1","result":"hello matthew"}
But when i switch to "named param" pattern as following:
@JsonRpcService("/test/jsonrpc")
public interface IBrokerRpc {
// TODO: DO NOT WORK. @JsonRpcParam(value = "name")
String hello(@JsonRpcParam(value = "name") String name);
}
I get an client error:
$ curl -H "Content-Type: application/json" -d '{"id":"1","jsonrpc":"2.0","method ":"hello","params":{"name":"matthew"}}' http://localhost:8080/test/jsonrpc
{"jsonrpc":"2.0","id":"1","error":{"code":-32602,"message":"method parameters in valid"}}
What is wrong? or do i need some other setting to support "named param"?
Best Regards.
I add the Annotation @JsonRpcParam(value = "name") also on “hello” method in implement class.
And then it works.
@Service
@AutoJsonRpcServiceImpl
public class BrokerRpc implements IBrokerRpc {
@Override
public String hello(@JsonRpcParam(value = "name") String name) {
return "hello " + name;
}
}
But, i think it's not essential.
Best Regards.
@JsonRpcErrors and @JsonRpcError also doasnt found in interface method declaration (its work in implementation methotds)