jnan77 / jsonrpc4j

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

JsonRpcParam annotations not found with CompositeJsonServiceExporter #28

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Named parameters don't work with CompositeJsonServiceExporter (jsonrpc4j 0.23).

Request:
{"jsonrpc":"2.0", "id":"10", "method":"getProduct", "params":{"id" :"1"}}
Gives:
{"jsonrpc":"2.0","id":"10","error":{"code":-32602,"message":"Invalid method 
parameters"}}

<bean id="productService" class="cz.service.impl.ProductServiceImpl" />
<bean id="categoryService" class="cz.service.impl.CategoryServiceImpl"/>
<bean name="export" 
class="com.googlecode.jsonrpc4j.spring.CompositeJsonServiceExporter">
        <property name="services">
            <list>
                <ref bean="productService"/>
                <ref bean="categoryService"/>
            </list>
        </property>
        <property name="serviceInterfaces">
            <list>
                <value>cz.service.ProductService</value>
                <value>cz.service.CategoryService</value>
            </list>
        </property>
</bean>

public interface ProductService {
    ProductDTO getProduct(@JsonRpcParam("id") String id);
}

public class ProductServiceImpl implements ProductService {
 @Override
    public ProductDTO getProduct(String id) {
        return new ProductDTO(id, "name");
    }
}

Positional parameters works:
{"jsonrpc":"2.0", "id":"10", "method":"getProduct", "params":["1"]}
{"jsonrpc":"2.0", "id":"10", "method":"getCategory", "params":["1"]}

If I use JsonServiceExporter and just one service it works as expected:
--> {"jsonrpc":"2.0", "id":"10", "method":"getProduct", "params":{"id":"1"}}
<-- {"jsonrpc":"2.0","id":"10","result":{"id":"1","name":"name"}}

Original issue reported on code.google.com by jiri.pej...@gmail.com on 25 Jun 2012 at 7:53

GoogleCodeExporter commented 8 years ago
I'll address this ASAP.

Original comment by brian.di...@gmail.com on 26 Jul 2012 at 5:35

GoogleCodeExporter commented 8 years ago
Unfortunately right now composite services only support indexed parameters.

This wouldn't be too hard of an issue to fix - if you could submit a test case 
then it would make it a lot easier to address.  My thinking is that the issue 
likely resides in the findBestMethodUsingParamNames method of the JsonRpcServer 
class.

Original comment by brian.di...@gmail.com on 31 Jul 2012 at 7:16

GoogleCodeExporter commented 8 years ago
This issue is now fixed by my patch attached to Issue#38.

Original comment by brett.wo...@gmail.com on 26 Sep 2012 at 3:41

GoogleCodeExporter commented 8 years ago
fixed in next release

Original comment by brian.di...@gmail.com on 6 Oct 2012 at 12:02