wadl2java生成的带有参数类型的接口

时间:2018-06-28 15:23:21

标签: cxf wadl

从WADL开始,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<application xmlns="http://wadl.dev.java.net/2009/02"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xmlns:ns="http://usermanagement"
             xmlns:core="http://core"
             xsi:schemaLocation="http://wadl.dev.java.net/2009/02 wadl.xsd">

    <grammars>
        <include href="usermanagement.xsd" />
    </grammars>

    <resources>
        <resource id="UserResource" path="/users">
            <doc>User resource with endpoints to manage users</doc>
            <resource path="/{id:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}}">
                <param name="id" required="true" style="template">
                    <doc>UUID of the user</doc>
                </param>
                <method id="getUser" name="GET">
                    <doc>Retrieve user by UUID</doc>
                    <response status="200">
                        <doc>User matching the UUID</doc>
                        <representation mediaType="application/json" element="ns:User" />
                        <representation mediaType="application/xml" element="ns:User" />
                    </response>
                    <response status="404">
                        <doc>User referred to by UUID could not be found</doc>
                        <representation mediaType="application/json" element="core:ExceptionDetails" />
                        <representation mediaType="application/xml"  element="core:ExceptionDetails" />
                    </response>
                </method>
        </resource>
    </resources>
</application>

usermanagement.xsd像这样:

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns:tns="http://usermanagement"
           targetNamespace="http://usermanagement">
    <xs:complexType name="User">
        <xs:complexContent>
            <xs:sequence>
                <xs:element name="Uuid" type="xs:string"/>
                <xs:element name="Number" type="xs:string" minOccurs="0"/>
            </xs:sequence>
        </xs:complexContent>
    </xs:complexType>
</xs:schema>

生成的接口如下所示:

@Path("/users")
public interface UserResource {
    @GET
    @Produces({"application/json", "application/xml" })
    @Path("/{id:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}}")
    User getUser(@PathParam("id") String id);
}

我可以通过哪种方式更改WADL定义,以使CXF wadl2javaidjava.lang.String生成参数java.util.UUID的类型?

我从JAX-RS基础知识guide看到它应该工作。

谢谢!

0 个答案:

没有答案