无法找到 MessageBodyReader
我有这个接口:
@Path("inbox")
public interface InboxQueryResourceTest {
@POST
@Path("{membershipExternalId}/query")
@Consumes(MediaType.APPLICATION_XML)
@Produces("multipart/mixed")
public MultipartOutput query(@PathParam("membershipExternalId") final String membershipExternalId,
@QueryParam("page") @DefaultValue("0") final int page,
@QueryParam("pageSize") @DefaultValue("10") final int pageSize,
@QueryParam("sortProperty") final List<String> sortPropertyList,
@QueryParam("sortReversed") final List<Boolean> sortReversed,
@QueryParam("sortType") final List<String> sortTypeString,
final InstanceQuery instanceQuery) throws IOException;
}
我已经实现了返回 MultipartOutput 的方法。 我从 Fiddler 发布了一个 xml 查询,并且毫无问题地收到了结果。
但是我已经对同一个接口进行了集成测试,我发送了相同的对象,并且我的响应如下:
final MultipartOutput multiPartOutput = getClient().query(getUserRestAuth(), 0, 25, null, null, null, instanceQuery);
但是在这里,从集成测试中,我收到一个奇怪的错误:
无法找到内容类型为 multipart/mixed;boundary="74c5b6b4-e820-452d-abea-4c56ffb514bb" 且类型为 org.jboss.resteasy.plugins.providers.multipart.MultipartOutput 的 MessageBodyReader
任何人都知道为什么只在集成中测试我收到此错误?
PS:有些人会说我不发送 application/xml 作为 ContentType 而是 multipart,这当然是错误的,因为对象用所需的 @XmlRootElement 等进行了注释,否则来自 Fiddler 的 POST 都不起作用。
I have this interface:
@Path("inbox")
public interface InboxQueryResourceTest {
@POST
@Path("{membershipExternalId}/query")
@Consumes(MediaType.APPLICATION_XML)
@Produces("multipart/mixed")
public MultipartOutput query(@PathParam("membershipExternalId") final String membershipExternalId,
@QueryParam("page") @DefaultValue("0") final int page,
@QueryParam("pageSize") @DefaultValue("10") final int pageSize,
@QueryParam("sortProperty") final List<String> sortPropertyList,
@QueryParam("sortReversed") final List<Boolean> sortReversed,
@QueryParam("sortType") final List<String> sortTypeString,
final InstanceQuery instanceQuery) throws IOException;
}
I have implemented the method to return a MultipartOutput.
I am posting an xml query from Fiddler and i receive the result without any problem.
BUT i have done an integration test for the same interface, i send the same objects and i put the response like:
final MultipartOutput multiPartOutput = getClient().query(getUserRestAuth(), 0, 25, null, null, null, instanceQuery);
But here, so from integration tests, i receive a strange error:
Unable to find a MessageBodyReader of content-type multipart/mixed;boundary="74c5b6b4-e820-452d-abea-4c56ffb514bb" and type class org.jboss.resteasy.plugins.providers.multipart.MultipartOutput
Anyone has any ideea why only in integration tests i receive this error?
PS: Some of you will say that i do not send application/xml as ContentType but multipart, which of course is false because the objects are annotated with the required @XmlRootElement etc, otherways neither the POST from Fiddler would work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
你可以试试这个:
You can try this:
类路径中是否包含用于多部分编码的相应 Resteasy 插件? (esteasy-multipart-provider)。
Are including in classpath the corresponding resteasy addon for multipart encoding? (esteasy-multipart-provider).
尝试将此方法添加到您的测试类中。这将注册已在您的服务器上注册的默认内置提供程序。
Try adding this method to your test class. This would register the default built-in providers which are already registered on your server.