我实现了一个简单的rest终结点,该终结点返回包含一个
的ResponseList<String>
由于我在项目中使用wildfly,因此该客户端是用jaxrs 2.0和resteasy来实现的。当我获取结果时,我会继续接受以下异常
javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/xml and type interface java.util.List
at org.jboss.resteasy.core.interception.ClientReaderInterceptorContext.throwReaderNotFound(ClientReaderInterceptorContext.java:42)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.getReader(AbstractReaderInterceptorContext.java:80)
at org.jboss.resteasy.core.interception.AbstractReaderInterceptorContext.proceed(AbstractReaderInterceptorContext.java:53)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readFrom(ClientResponse.java:324)
at org.jboss.resteasy.client.jaxrs.internal.ClientResponse.readEntity(ClientResponse.java:251)
at org.jboss.resteasy.specimpl.BuiltResponse.readEntity(BuiltResponse.java:245)
这是产生错误的客户端代码。如果我请求JSON,则可以正常工作,但使用xml时,会出现上述异常。
Invocation.Builder request = rTarget.path("/containers/instances/{id}/kbase/{kbaseName}").resolveTemplate("id", containerAlias).resolveTemplate("kbaseName", getKbase()).
request(MediaType.APPLICATION_XML).accept(MediaType.APPLICATION_XML);
return request.get().readEntity(new GenericType<List<String>>(){});
这是我到目前为止的工作量
<!-- Test scope dependencies -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-client</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jboss.resteasy/jaxrs-api -->
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>jaxrs-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson-provider</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jaxb-provider</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-multipart-provider</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jettison-provider</artifactId>
<scope>test</scope>
</dependency>
任何帮助,我们将不胜感激。预先感谢