Yohan is a Senior Technical Lead specialising in Java and related technologies. His interests are in Software Architecture, API Design and Development, Enterprise Integration, Messaging, Distributed Computing and Parallel computing. Yohan is a DZone MVB and is not an employee of DZone and has posted 16 posts at DZone. You can read more from them at their website. View Full User Profile

JAX-WS: Working with .NET Web Services

  • submit to reddit

If you happen to write a JAX-WS Web Services client for a service which is written using .NET Platform, you might come across the below error message when you execute wsimport command.

A class/interface with the same name “?????” is already in use. Use a class customization to resolve this conflict.

This happens because .NET generated WSDL documents may contain multiple elements with same name, which leads to a naming conflict when JAXB attempts to generate bindings. If you ever come across this situation, the solution is very simple. You just have to instruct the JAXB generator to automatically resolve any naming conflicts that might occur during the code generation. This can be done by providing -B-XautoNameResolution argument to wsimport tool. Note that the ‘-B-XautoNameResolution’ has no spaces. -B is used to pass instructions to JAXB Schema Compiler.

An example would be:

wsimport -d gen-src -verbose -B-XautoNameResolution  https://sample.net/service.asmx?WSDL

Note that generated code will refer to duplicate names with a numeric suffix. For example, if there are two elements with name ‘XYZ’, one class will be ‘XYZ’, and the other occurrence will be named as ‘XYZ2′.

Published at DZone with permission of Yohan Liyanage, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Sivaprasadreddy... replied on Tue, 2012/07/10 - 6:57am

Thank you Yohan. Come in handy today :-) You saved me a lot of time.

But my scenario is I have to generate java classes from XSD files.

Here I used c:\>xjc -d c:/xsd -p com.model -XautoNameResolution amzn-envelope.xsd

xjc doesn't recognize  -B-XautoNameResolution argument.



Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.