【发布时间】:2014-08-30 10:59:46
【问题描述】:
我有一个这样配置的 jaxrs 客户端:
<jaxrs:client id="opaRestProxy" name="opaRestProxy"
address="${endpoint}" serviceClass="com.test.RestProxy"
inheritHeaders="true" threadSafe="true">
<jaxrs:headers>
<entry key="Accept" value="application/json" />
<entry key="Content-Type" value="application/json" />
</jaxrs:headers>
</jaxrs:client>
但是当我发送请求时,我得到以下异常:
Caused by: org.apache.cxf.interceptor.Fault: .No message body writer has been found for class : class com.test.RequestObject, ContentType : application/json.
at org.apache.cxf.jaxrs.client.ClientProxyImpl$BodyWriter.handleMessage(ClientProxyImpl.java:646)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:263)
at org.apache.cxf.jaxrs.client.ClientProxyImpl.doChainedInvocation(ClientProxyImpl.java:527)
... 47 more
我的 RestProxy 类如下所示:
@Component
public interface RestProxy {
@POST
@Path("/getSomething")
String getSomething(RequestObject RequestObject);
}
【问题讨论】:
-
您使用的是特定的 JSON 库吗?听起来您没有配置提供程序。
-
@Patrick 如何为 Jackson 这样的库配置提供程序