【问题标题】:Enunciate not can't determine output type for javax.ws.rs.core.ResponseEnunciate 无法确定 javax.ws.rs.core.Response 的输出类型
【发布时间】:2011-03-11 22:21:11
【问题描述】:

我有一个返回“javax.ws.rs.core.Response”实体的 REST Web 服务。当我运行 enunciate 时,它​​无法确定输出类型,所以生成的 wadl 中的响应留空:

如果代码如下所示:

@GET
@Path("/webservice")
@Produces({"application/xml"})
@TypeHint(myClass.class)
javax.ws.rs.core.Response methodCall(...

WADL 内容如下:

    ...
    <wadl:representation mediaType="application/xml"/>
</wadl:response>

而不是:

    ...
    <wadl:representation mediaType="application/xml" element="ns1:myClass" xmlns:ns1="http://pathTo/schema"/>
</wadl:response>

不管怎样,这里是为了清楚地识别响应返回类型吗?

【问题讨论】:

    标签: java response jax-rs httpresponse enunciate


    【解决方案1】:

    是的。在方法上使用@org.codehaus.enunciate.jaxrs.TypeHint 注解为Enunciate 提供有关输出类型的提示。

    【讨论】:

    • 我在我的方法和“import org.codehaus.enunciate.jaxrs.TypeHint;”中添加了“@TypeHint(my.class)”。在我的 pom.xml 中,我添加了以下 xml,但它似乎并没有改变输出。我还需要做什么吗? org.codehaus.enunciateenunciate-core-annotations1.21.1
    • 所以,我们有测试证明@TypeHint 注解是有效的。你可以在这里看到测试模块:svn.codehaus.org/enunciate/trunk/enunciate/integration-tests/…
    • 事实证明,当@TypeHint 中标识的类在它所在的 maven 模块外部时,enunciate 可能会出现问题。(请参阅jira.codehaus.org/browse/…)。我将访问 Ryan 的答案。
    • 如果类型是对象列表,如何?
    • @kalyan 目前在类型提示中绝对不支持任何类型的泛型-y 内容。
    猜你喜欢
    • 2020-07-07
    • 2021-04-28
    • 2019-11-29
    • 2019-11-15
    • 1970-01-01
    • 1970-01-01
    • 2019-04-21
    • 2014-01-10
    • 2014-02-01
    相关资源
    最近更新 更多