我有一个CXF服务(2.5.2),它使用JSON对象并生成如下的JSON对象
@POST
@Produces({"application/json"})
@Consumes({"application/json"})
public AResponseObject register(@PathParam("param1") String param1, User user) {
//
}
CXF为上述服务生成的WADL如下:
<application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<script id="tinyhippos-injected"/>
<grammars/>
<resources base="http://host/...">
<resource path="/register/{param1}">
<param name="param1" style="template" type="xs:string"/>
<method name="POST" id="register">
<request>
<representation mediaType="application/json"/>
</request>
<response>
<representation mediaType="application/json"/>
</response>
</method>
</resource>
</resources>
</application>
以上WADL文件: -
未提供用户对象在语法部分
资源未指定该方法在请求中需要User对象 有效载荷
如何将这些丢失的内容添加到WADL文件中?
感谢。
答案 0 :(得分:0)
您需要在Blueprint文件中添加cxf WadlGenerator作为提供程序:
<bean id="wadlGenerator" class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
<property name="linkJsonToXmlSchema" value="true" />
</bean>
<jaxrs:server id="someRestService" address="/my/endpoint">
<jaxrs:serviceBeans>
<ref component-id="someRestServiceBean" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<ref component-id="wadlGenerator" />
<ref component-id="jsonProvider" />
</jaxrs:providers>
</jaxrs:server>