jnan77 / jsonrpc4j

Automatically exported from code.google.com/p/jsonrpc4j
0 stars 0 forks source link

id cannot be param name if jackson is used #2

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
I do not know if it is a bug, but I cannot find any limitations to param names 
at http://groups.google.com/group/json-rpc/web/json-rpc-2-0

1. service method with id as input param
public interface MainService {
    MasterDTO get(Long id);
} 

2. using Jackson mapper
    <bean id="mainService" class="MainServiceImpl" />

    <bean id="jsonEngine" class="com.googlecode.jsonrpc4j.spring.JacksonJsonEngineFactoryBean" />

    <bean name="/MainService.json" class="com.googlecode.jsonrpc4j.spring.JsonServiceExporter">
        <property name="service" ref="mainService"/>
        <property name="serviceInterface" value="MainService"/>
        <property name="jsonEngine" ref="jsonEngine" />
    </bean>

3. simple test
    @Test
    public void testGet() throws Exception {
        final MockHttpServletRequest request = new MockHttpServletRequest();
        final MockHttpServletResponse response = new MockHttpServletResponse();

        final String method = "get";
        final Map<String, Object> params = new HashMap<String, Object>();
        params.put("id", 999);

        final Object contentObj= this.jsonEngine.createRpcRequest(method, params );
        final ByteArrayOutputStream out = new ByteArrayOutputStream();
        jsonEngine.writeJson(contentObj, out);
        final String content = out.toString();

        request.setContent(content.getBytes());
        request.setMethod("POST");

        this.exporter.handleRequest(request, response);

        assertNotNull(response);

        System.out.println(response.getContentAsString());
    }

What is the expected output? What do you see instead?

I expected data, error response as you can check at log:

DEBUG c.g.j.spring.JsonServiceExporter handleRequest:101 - rpcRequest: 
{"jsonrpc":"2.0","method":"get","id":"060a4f0d-bb59-4682-bd70-0c61b5aa5de7","par
ams":{"id":999}} 
ERROR c.g.j.spring.JsonServiceExporter handleSingleRequest:219 - Invalid 
parameters to method: get 
{"result":null,"error":{"message":"Invalid 
Parameters","data":null,"code":-32602},"jsonrpc":"2.0","id":"060a4f0d-bb59-4682-
bd70-0c61b5aa5de7"}

What version of the product are you using? On what operating system?

        <dependency>
            <groupId>com.googlecode</groupId>
            <artifactId>jsonrpc4j</artifactId>
            <version>0.5-SNAPSHOT</version>
        </dependency>

Please provide any additional information below.

best luck

Original issue reported on code.google.com by mm001.ba...@gmail.com on 22 Jul 2010 at 1:34

GoogleCodeExporter commented 8 years ago
PLEASE IGNORE
failed to add annotation

Original comment by mm001.ba...@gmail.com on 23 Jul 2010 at 11:02

GoogleCodeExporter commented 8 years ago

Original comment by brian.di...@gmail.com on 3 Dec 2010 at 4:29

GoogleCodeExporter commented 8 years ago

Original comment by brian.di...@gmail.com on 26 May 2012 at 2:42