Apache CXF - 阐明 wsdl 生成错误

发布于 2024-09-06 18:16:41 字数 887 浏览 3 评论 0原文

我们使用 Apache CXF 代码优先方法来创建 Web 服务。我们有一个自定义的肥皂头来传递用户凭据。

我正在尝试使用 @webparam 注释传递 ​​SEI 中的用户凭据。

这是 Service 类中的两个操作。

@Path("/item/{id}")
@GET
public Item getItem(@PathParam("id") String id,
 @WebParam(name="userDetails", header=true, mode=Mode.IN) UserDetails details) throws NotFoundException;

@Path("/name/{id}")
@GET
public Item getItemByName(@PathParam("id") String id,
 @WebParam(name="userDetails", header=true, mode=Mode.IN) UserDetails details) throws NotFoundException;

生成 wsdl 时阐明会抛出错误

D:\workspace\myService\src\main\java\com\ws\api\ItemPublicationWebService.java:52: [xml] Web 方法定义一个名为“userDetails”的消息部分,该部分与 Web 的名称相同消息部分定义在 D:\workspace\myService\src\main\java\com\ws\api\ItemPublicationWebService.java:41 中。请使用注释来消除歧义。

我发现保持 webParam 名称唯一将生成 wsdl。但这不是预期的结果。

我在这里缺少什么?

We are using Apache CXF code-first approach to create web-services. We have a custom soap header to pass user credentials.

I am trying to pass the usercredentials in the SEI using a @webparam annotation.

These are two operations in the Service class.

@Path("/item/{id}")
@GET
public Item getItem(@PathParam("id") String id,
 @WebParam(name="userDetails", header=true, mode=Mode.IN) UserDetails details) throws NotFoundException;

@Path("/name/{id}")
@GET
public Item getItemByName(@PathParam("id") String id,
 @WebParam(name="userDetails", header=true, mode=Mode.IN) UserDetails details) throws NotFoundException;

Enunciate while generating the wsdl throws an error saying

D:\workspace\myService\src\main\java\com\ws\api\ItemPublicationWebService.java:52: [xml] Web method defines a message part named 'userDetails' that is identical to the name of a web message part defined in D:\workspace\myService\src\main\java\com\ws\api\ItemPublicationWebService.java:41. Please use annotations to disambiguate.

I found out that keeping the webParam name unique will generate the wsdl. But that is not the expected result.

What am I missing here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

红颜悴 2024-09-13 18:16:41

Enunciate 在这里所做的就是尝试为您的 Web 服务 API 构建一个漂亮、干净、整合的 WSDL。 Enunciate 与其他 WSDL 生成器不同,因为它在编译时工作,并尝试将所有标头元素分组到 WSDL 可以引用的单个统一的 XML 模式文件中。 (其他 WSDL 生成器在运行时工作,因此可以根据需要动态生成模式,但是存在大量重复的 XML 元素等。)

因此,当 Enunciate 遇到“getItem”方法时,它会看到 header 元素命名为“userDetails”,并将该 XML 元素添加到正在生成的 XML 架构文档中。然后,Enunciate 遇到您的“getItemByName”方法,并发现还有另一个名为“userDetails”的标头元素,但它不够智能,无法看出它们是相同的元素。因此认为存在冲突,就会引发错误。

我已经为您记录了 JIRA 问题:

http://jira.codehaus.org/browse/ ENUNCIATE-453

现在,如果您不关心 Enunciate 为您生成 WSDL,您可以禁用“xml”Enunciate 模块:

<enunciate...>
  ...
  <modules>
    <xml disabled="true"/>
  </modules>
</enunciate>

What Enunciate's doing here is trying to build out a nice, clean, consolidated WSDL for your Web service API. Enunciate is different from other WSDL generators because it works at compile-time and tries to group all your header elements into a single, consolidated XML schema file that the WSDL can reference. (Other WSDL generators work at runtime and can therefore generate the schemas as-needed, on the fly, but there's a lot of duplication of XML elements, etc.)

So when Enunciate comes across your "getItem" method, it sees the header element named "userDetails" and adds that XML element to its XML schema document that's being generated. Then, Enunciate comes across your "getItemByName" method and sees that there's yet another header element named "userDetails" and it isn't smart enough to see that they're the same element. So thinking that there's a conflict, it throws an error.

I've logged a JIRA issue for you:

http://jira.codehaus.org/browse/ENUNCIATE-453

For now, if you don't care about having Enunciate generate your WSDL for you, you can disable the 'xml' Enunciate module:

<enunciate...>
  ...
  <modules>
    <xml disabled="true"/>
  </modules>
</enunciate>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文