Hello,

I need to POST more than one parameter. Is this possible through
@Multipart/@FormParam or something? Here is the service method I need:

    @POST
    @Path("/postdata2")
    @Produces("application/json")
    public String postData2(@Multipart("list1")
@XmlJavaTypeAdapter(XmlMapAdapter.class) List<Map&lt;String, String>> list1,
@Multipart("testItem2") TestItem t2);

My TestItem is annotated with @XmlRootElement. When I call from my jaxrs
client, it throws the following exception.

SEVERE: Resource method service.rs.TestService.postData2 has more than one
parameter representing a request body
Exception in thread "main"
org.apache.cxf.jaxrs.client.ClientWebApplicationException: Resource method
service.rs.TestService.postData2 has more than one parameter representing a
request body
        at
org.apache.cxf.jaxrs.client.ClientProxyImpl.reportInvalidResourceMethod(ClientProxyImpl.java:546)
        at
org.apache.cxf.jaxrs.client.ClientProxyImpl.getParametersInfo(ClientProxyImpl.java:214)
        at
org.apache.cxf.jaxrs.client.ClientProxyImpl.invoke(ClientProxyImpl.java:138)
        at $Proxy20.postData2(Unknown Source)
        at service.TestServiceClient.main(TestServiceClient.java:82)

>From http://cxf.apache.org/docs/jax-rs-multiparts.html it seems that what I
need should be possible, since it has an example that says (from
http://svn.apache.org/repos/asf/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/MultipartStore.java):

    @POST
    @Path("/books/jaxb2")
    @Consumes("multipart/related;type=\"text/xml\"")
    @Produces("text/xml")
    public Response addBookParts(@Multipart("rootPart") Book b1,
                                 @Multipart("book2") Book b2) 
        throws Exception {
        if (b1.equals(b2)) {
            throw new WebApplicationException();
        }
        if (!b1.getName().equals(b2.getName())) {
            throw new WebApplicationException();
        }
        b1.setId(124);
        return Response.ok(b1).build();
    }

Thanks

--
View this message in context: 
http://cxf.547215.n5.nabble.com/Resource-method-has-more-than-one-parameter-representing-a-request-body-tp5550174p5550174.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to