开发者

Using MessageBodyReader for multiple parameters in RESTful services

The following method does not allow my servlet container to start:

@PUT
public String upload(final Customer customer, final Control control) {
  // ...
}

I get, not surprisingly:

SEVERE: Missing dependency for method ... at index 0
SEVERE: Missing dependency for method ... index 1
SEVERE: Method, ..., is not recognized as valid resourc开发者_如何转开发e method.

I have implemented MessageBodyReaders for each type. Removing any of the parameters enables the servlet container to start gracefully, so I suspect there must be a restriction on the number of parameters that will be resolved via Entity-Providers.

The problem is that I NEED these two parameters, since I am providing both SOAP and REST support, and of course, I am not in the liberty of changing method signatures, and I also do not want to create one specific Jersey method and one specific JAX-WS method as entry points.

I'm using Jersey 1.7.


JAX-RS allows only one entity parameter. The reson is very simple: each request may have at most one body (multiparts are not supported by spec) So you must create two methods. Btw, I don't think it's a good practice to mix JAXRS and JAXWS in the same class.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜