views:

157

answers:

2

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.

Can anyone please point me what am I missing here?

Any Help would be appreciated.

A: 

Hi.

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>
Ryan Heaton
That issue has been resolved now.
Ryan Heaton