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;
}
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>
以下は、サービスのサービス構成と、wadl の json 表現を取得するための 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>