Apache CXF JAX-RS表示元素未定义



使用Jackson(1.9.13)和Apache CXF(2.7.11),生成的WADL不包含参数或响应表示上的"element"节点(因此定义了输入/返回类型是什么),尽管它在"语法"中被正确地定义了。我的返回对象上确实有一个名称空间和@XMLRootElement(因此它会出现在语法中),但是元素仍然没有在类型上定义。如有任何意见,欢迎指教。

这是我的对象:

@XmlRootElement(name = "testObject", namespace = "http://test.com/test")
public class TestObject {
private String sparky;
private String skippy;
private int goober;
public TestObject() {
    // TODO Auto-generated constructor stub
}
public String getSparky() {
    return sparky;
}
public void setSparky(String sparky) {
    this.sparky = sparky;
}
public String getSkippy() {
    return skippy;
}
public void setSkippy(String skippy) {
    this.skippy = skippy;
}
public int getGoober() {
    return goober;
}
public void setGoober(int goober) {
    this.goober = goober;
}
}

我的JAX-RS服务类(作为返回和请求类型):

@Path("/testservice")
@WebService
@Produces(MediaType.APPLICATION_JSON)
public class TestService {
@Path("/getTestObject2")
@GET
@WebMethod
@ElementClass(response=TestObject.class)
public TestObject getTestObject2(@QueryParam("skippy") String skippy) {
        TestObject myReturn = new TestObject();
        myReturn.setGoober(1);
        myReturn.setSkippy("Yep. It's skippy" + 1);
        myReturn.setSparky("Here sparky. Here boy" + 1);
        return myReturn;
}
@Path("/getTestObject3")
@POST
@WebMethod
@ElementClass(request=TestObject.class)
public String getTestObject3(@QueryParam("skippy") TestObject skippy) {
        TestObject myReturn = new TestObject();
        myReturn.setGoober(1);
        myReturn.setSkippy("Yep. It's skippy" + 1);
        myReturn.setSparky("Here sparky. Here boy" + 1);
        return "goo";
}
}

和我生成的WADL:

<application xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://wadl.dev.java.net/2009/02">
<grammars>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://test.com/test" elementFormDefault="unqualified" attributeFormDefault="unqualified" targetNamespace="http://test.com/test">
        <xs:complexType name="testObject">
            <xs:sequence>
                <xs:element name="goober" type="xs:int"/>
                <xs:element name="skippy" type="xs:string" minOccurs="0"/>
                <xs:element name="sparky" type="xs:string" minOccurs="0"/>
            </xs:sequence>
        </xs:complexType>
    </xs:schema>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://test.com/test" elementFormDefault="unqualified" attributeFormDefault="unqualified" targetNamespace="http://test.com/test">
        <xs:import/>
        <xs:element name="testObject" type="testObject"/>
    </xs:schema>
</grammars>
<resources base="http://localhost:8080/fedapp/test/frankwebservice/services/jaxrs">
    <resource path="/testservice">
        <resource path="/getTestObject2">
            <method name="GET">
                <request>
                    <param name="skippy" type="xs:string" style="query"/>
                </request>
                <response>
                    <representation mediaType="application/json"/>
                </response>
            </method>
        </resource>
        <resource path="/getTestObject3">
            <method name="POST">
                <request>
                    <param name="skippy" style="query"/>
                </request>
                <response>
                    <representation mediaType="application/json">
                        <param name="result" type="xs:string" style="plain"/>
                    </representation>
                </response>
            </method>
        </resource>
    </resource>
</resources>
</application>

尝试在TestObject skippy上使用@QueryParam(")而不是@QueryParam("skippy") TestObject skippy

最新更新