[英]WADL in json in CXF
I need to generate the json representation of wadl of a REST service in json: 我需要在json中生成REST服务的wadl的json表示形式:
@Description("Service for reading books")
@Path("/bookService")
public interface BookService
{
@GET
@Path("/getBook")
@Produces(
{"application/xml",
"application/json"})
@Description("Get Book for a given id")
public Book getBook(@QueryParam("bookId") Integer id) throws Exception;
}
On localhost:8080/services/?_wadl gives me 在localhost:8080 / services /?_ wadl给我
<application xmlns="http://wadl.dev.java.net/2009/02"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<grammars />
<resources base="http://localhost:8080/services/">
<resource path="/bookService" id="books.rs.BookServiceImpl">
<doc>Service for reading books.</doc>
<resource path="/getBook">
<method name="GET" id="getBook">
<doc>Get Book for a given id</doc>
<request>
<param name="bookId" style="query" type="xs:int" />
</request>
<response>
<representation mediaType="application/xml" />
<representation mediaType="application/json" />
</response>
</method>
</resource>
</resource>
</resources>
</application>
Below is the service config for the service and what should be the json schema here to get the json representation of wadl 下面是该服务的服务配置,这里的json模式应该是什么才能获取wadl的json表示形式
<jaxrs:server id="restContainer" address="/">
<jaxrs:serviceBeans>
<ref bean="bookService" />
</jaxrs:serviceBeans>
<jaxrs:providers>
<bean id="jacksonJsonProvider" class="org.codehaus.jackson.jaxrs.JacksonJsonProvider" />
<bean class="org.apache.cxf.jaxrs.model.wadl.WadlGenerator">
<property name="linkJsonToXmlSchema" value="true" />
<property name="schemaLocations">
<list>
<value>classpath:/json.schema</value>
</list>
</property>
<property name="useJaxbContextForQnames" value="true" />
<property name="ignoreMessageWriters" value="true" />
<property name="addResourceAndMethodIds" value="true" />
</bean>
<bean id="jsonProvider" class="org.apache.cxf.jaxrs.provider.json.JSONProvider">
<property name="serializeAsArray" value="true" />
</bean>
</jaxrs:providers>
</jaxrs:server>
尝试对JSON使用?_wadl&_type=xml
json和对xml尝试?_wadl&_type=json
xml
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.