开发者

Using MessageBodyReader for multiple parameters in RESTful services

开发者 https://www.devze.com 2023-03-12 19:07 出处:网络
The following method does not allow my servlet container to start: @PUT public String upload(final Customer customer, final Control control) {

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

精彩评论

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