Friday, January 1, 2010

Little Issue Consuming a Web Service

Today i had a little issue consuming a web service with Apache CXF. Normally it is very straightforwarding, you use the wsdl2java console tool and voila you have the classes you need.

But not today, CXF didn't like the wsdl definition and throw a little error:

WSDLToJava Error: Thrown by JAXB : A class/interface with the same name "*************" is already in use. Use a class customization to resolve this conflict.

So then i started looking a Customizing JAXB Bindings because the error suggested that. I wasn't that happy, i didn't wanted to spend a while unterstanding the inside and out of those bindings.

Reading a bit more about the flags and options of wsdl2java i found this very nice option called autoNameResolution which in the documentation had the following explanation.

-autoNameResolution (Automatically resolve naming conflicts without requiring the use of binding customizations)

I also added an error description and solution in devblood: Read Here.

Additionally i added an issue to the CXF Project, they could mention the autoNameResolution option in their message error, i think it would be of great help for some people out there.

You can check out the issue here.

Happy Coding.

Klaus Stefan Gerber
Bangkok, Thailand

No comments: