我现在因为以下问题而苦苦挣扎了几天。 我创建了一个简单的球衣2项目。 这是我的JerseyConfig
public class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
property(ServerProperties.WADL_GENERATOR_CONFIG, "com.platform.config.jersey.EpWadlGeneratorConfig");
register(ProjectPolicyCounterWebService.class);
}
}
我也有这个发电机配置:
public class EpWadlGeneratorConfig extends WadlGeneratorConfig {
@Override
public List<WadlGeneratorDescription> configure() {
return generator(WadlGeneratorApplicationDoc.class)
.prop("applicationDocsStream", "ws/wadl/application-doc.xml")
.generator(WadlGeneratorResourceDocSupport.class)
.prop("resourceDocStream", "resourcedoc.xml")
.generator(WadlGeneratorGrammarsSupport.class)
.prop("grammarsStream", "ws/wadl/application-grammars.xml")
.prop("overrideGrammars", true)
.generator(WadlGeneratorResourceDocSupport.class)
.prop("resourceDocStream", "ws/wadl/resourcedoc.xml")
.descriptions();
}
}
我创建了适当的resourcedoc.xml,application-grammars.xml,application-doc.xml。但我对这个控制器的wadl
@GET
@Produces({MediaType.APPLICATION_XML})
@Path("type")
public NumberResponseType type() {
NumberResponseType type = new NumberResponseType ();
type.setNumbersFreeAmount(23423L);
type.setDateResponse(new XMLGregorianCalendarImpl());
type.setErrorList(new ErrorListType());
return type;
}
不要在响应类型中包含我的元素
<ns2:application xmlns:ns2="http://wadl.dev.java.net/2009/02">
<ns2:doc title="A message in the WADL" xml:lang="en">
This is added to the start of the generated application.wadl
</ns2:doc>
<ns2:doc xmlns:jersey="http://jersey.java.net/" jersey:generatedBy="Jersey: 2.19 2015-06-29 13:02:58"/>
<ns2:doc xmlns:jersey="http://jersey.java.net/" jersey:hint="This is simplified WADL with user and core resources only. To get full WADL with extended resources use the query parameter detail. Link: http://localhost:9000/api/application.wadl?detail=true"/>
<ns2:grammars>
<ns2:include href="/ws/xsd/NumberResponseType.xsd"/>
</ns2:grammars>
<ns2:resources base="http://localhost:9000/api/">
<ns2:resource path="/">
<ns2:resource path="type">
<ns2:method id="type" name="GET">
<ns2:response>
<ns2:representation mediaType="application/xml"/>
</ns2:response>
</ns2:method>
</ns2:resource>
</ns2:resource>
</ns2:resources>
</ns2:application>
我做错了什么?