在 RESTful 服务中使用 MessageBodyReader 获取多个参数
以下方法不允许我的 servlet 容器启动:
@PUT
public String upload(final Customer customer, final Control control) {
// ...
}
毫不奇怪,我得到了:
SEVERE: Missing dependency for method ... at index 0
SEVERE: Missing dependency for method ... index 1
SEVERE: Method, ..., is not recognized as valid resource method.
我已经为每种类型实现了 MessageBodyReaders。删除任何参数都可以使 servlet 容器正常启动,因此我怀疑必须对通过实体提供程序解析的参数数量进行限制。
问题是我需要这两个参数,因为我同时提供 SOAP 和 REST 支持,当然,我无权更改方法签名,而且我也不想创建一种特定的 Jersey 方法和一种特定的 JAX-WS 方法作为入口点。
我正在使用泽西岛 1.7。
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 resource 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
JAX-RS 只允许一个实体参数。原因很简单:每个请求最多只能有一个主体(规范不支持多部分)
所以您必须创建两个方法。
顺便说一句,我认为在同一个类中混合使用 JAXRS 和 JAXWS 并不是一个好的做法。
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.