简体   繁体   English

Apache CXF-阐明wsdl生成错误

[英]Apache CXF -Enunciate wsdl generation Error

We are using Apache CXF code-first approach to create web-services. 我们正在使用Apache CXF代码优先方法来创建Web服务。 We have a custom soap header to pass user credentials. 我们有一个自定义的soap标头来传递用户凭据。

I am trying to pass the usercredentials in the SEI using a @webparam annotation. 我正在尝试使用@webparam批注在SEI中传递用户凭据。

These are two operations in the Service class. 这是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;

Enunciate while generating the wsdl throws an error saying 生成wsdl时发出错误消息,提示错误

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. 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中。 Please use annotations to disambiguate. 请使用注释来消除歧义。

I found out that keeping the webParam name unique will generate the wsdl. 我发现保持webParam名称唯一将生成wsdl。 But that is not the expected result. 但这不是预期的结果。

What am I missing here? 我在这里想念什么?

What Enunciate's doing here is trying to build out a nice, clean, consolidated WSDL for your Web service API. Enunciate在这里所做的就是尝试为您的Web服务API构建一个很好的,干净的,统一的WSDL。 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. Enunciate与其他WSDL生成器不同,因为它在编译时起作用,并尝试将所有标头元素分组到一个WSDL可以引用的统一的XML模式文件中。 (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.) (其他WSDL生成器在运行时工作,因此可以根据需要即时生成模式,但是XML元素有很多重复等)。

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. 因此,当Enunciate遇到您的“ getItem”方法时,它将看到名为“ userDetails”的标头元素,并将该XML元素添加到正在生成的XML模式文档中。 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. 然后,Enunciate遇到您的“ getItemByName”方法,并发现还有一个名为“ userDetails”的标头元素,并且不够聪明地看到它们是同一元素。 So thinking that there's a conflict, it throws an error. 因此,认为存在冲突会引发错误。

I've logged a JIRA issue for you: 我已经为您记录了JIRA问题:

http://jira.codehaus.org/browse/ENUNCIATE-453 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为您生成WSDL,则可以禁用'xml'Enunciate模块:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM