Named based parameters and CompositeJsonServiceExporter

53 views
Skip to first unread message

Jiří Pejchal

unread,
Jun 24, 2012, 8:21:36 AM6/24/12
to json...@googlegroups.com
What is the correct way of configuring CompositeJsonServiceExporter with spring?
It seems to me that @JsonRpcParam annotations are not found.

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"}}

Jiří Pejchal

Brian

unread,
Jun 24, 2012, 4:34:53 PM6/24/12
to json...@googlegroups.com
Hmm, so the problem you're having is that annotated parameters aren't working with the composite services.  Please open a bug for this and I'll look into it ASAP.
Reply all
Reply to author
Forward
0 new messages