9

I have a wsdl that was generated by .NET that I am trying to consume in a java application. To do this, I am trying to use the CXF Wsdl2Java tool. The problem is that when the tool runs, it throws a jaxb exception:

Thrown by JAXB: Two declarations cause a collision in the ObjectFactory class.

I understand that I probably need to create a custom binding file to rename an object at build time, but I have no idea where to start. How do I find out which objects in the wsdl are causing the problems?

(It seems like it would be nice if the exception actually said which elements were causing the naming conflict)

JamesP
  • 91
  • 1
  • 2

2 Answers2

1

This might work:

  1. tell cxf to resolve name collision with : -autoNameResolution command line argument
  2. tell jaxb to not remove underscores with : jaxb:globalBindings underscoreBinding="asCharInWord"
André Ricardo
  • 3,051
  • 7
  • 23
  • 32
  • Source URL is not available any more... :( – predrags Apr 09 '21 at 07:24
  • 1
    @predrags sorry, it's a rather old answer and it's not on Web Archive. The options for cxf are documented here https://cxf.apache.org/docs/wsdl-to-java.html For the jaxb customization https://docs.oracle.com/cd/E17802_01/webservices/webservices/docs/1.5/tutorial/doc/JAXBUsing4.html#wp148515 An example for customizing this underscoreBinding https://stackoverflow.com/a/4146742/388038 – André Ricardo Apr 10 '21 at 10:37
0

In addition to the above, make sure you are using the latest version of CXF's wsdl2java tool. The latest versions have done a better job of trying to get the line/col numbers of where JAXB is finding these types of errors. That at least can give a basic indication of where to look, but they still aren't easy to track down.

Daniel Kulp
  • 14,447
  • 4
  • 45
  • 37