开发者

List like param in Resteasy Service

Good mournig guys!

How to send a List like param to a Resteasy service?

When I'll execute throws the exception follow:

java.lang.RuntimeException: could not find writer for content-type multipart/mixed type: java.util.ArrayList
    at org.jboss.resteasy.client.ClientRequest.writeRequestBody(ClientRequest.java:474)
    at org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor$ClientRequestEntity.<init>(ApacheHttpClientExecutor.java:154)
    at org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor.loadHttpMethod(ApacheHttpClientExecutor.java:226)
    at org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor.execute(ApacheHttpClientExecutor.java:78)
    at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:39)
    at org.jboss.resteasy.plugins.interceptors.encoding.AcceptEncodingGZIPInterceptor.execute(AcceptEncodingGZIPInterceptor.java:40)
    at org.jboss.resteasy.core.interception.ClientExecutionContextImpl.proceed(ClientExecutionContextImpl.java:45)
    at org.jboss.resteasy.client.ClientRequest.execute(ClientRequest.java:449)
    at org.jboss.resteasy.client.ClientRequest.httpMethod(ClientRequest.java:679)
    at org.jboss.resteasy.client.ClientRequest.put(ClientRequest.java:541)
    at org.jboss.resteasy.client.ClientRequest.put(ClientRequest.java:546)
    at Principal.main(Principal.java:74)

My service is declared this form:

    @PUT
    @Path("gravarBoletos")
    @Consumes("multipart/mixed")
    @Produces(MediaType.TEXT_PLAIN)
    public Integer gravarBoletos(List<TituloTO> tituloTOs) throws ExcecaoSistema, ExcecaoNegocio;

I call in my client this form:

    ClientRequest request = new ClientRequest(urlWebService + "/mFinanceiroService/gravarBoletos");

    request.accept("multipart/mixed");
    request.body("multipart/mixed", tituloImport.getTituloTOs());

    ClientResponse<Integer> response = request.put(Integer.class);

  开发者_运维技巧  System.out.println(response.getEntity());

Anybody help me???? Thanks!


Use the @Wrapped annotation.

@GET
@Path("list")
@Produces("application/xml")
@Wrapped(element="list", namespace="http://foo.org", prefix="foo")
public List<Customer> getCustomerSet(){
    List<Customer> list = new ArrayList<Customer>();
    list.add(new Customer("bill"));
    list.add(new Customer("monica"));

    return list;
}

Would return this xml:

 <foo:list xmlns:foo="http://foo.org">
      <customer><name>bill</name></customer>
      <customer><name>monica</name></customer>
 </foo:list>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜