title

fire chief's random developer tidbits

Monday, April 2, 2012

Two declarations cause a collision in the ObjectFactory class.

Given a wsdl generated by .net(c#) with inline object specifications, JAX-WS will have trouble with the naming of some of the objects and give the error "Two declarations cause a collision in the ObjectFactory class.".  This seems to be the most common problem with JAX-WS and finding the right recipe was problematic.  Netbeans (7.1.1) didn't help things because the maven plugin code it generated is a very outdated version (1.10 from codehaus).  Upgrading that (not absolutely sure if it was required) using this guide seemed to help: http://jax-ws-commons.java.net/jaxws-maven-plugin/ (and specifically http://jax-ws-commons.java.net/jaxws-maven-plugin/examples/using-jaxb-plugins.html). A co-worker and I tried a lot of combinations to get autoNameResolution working, because that seems to be the answer that works for a lot of other people.  We never did get that to work.  What did work was getting a correctly formatted binding file with references to all the right namespaces so the xpath would work and the problematic object could be renamed.  This page provided an important clue on the format:  http://docs.oracle.com/javaee/5/tutorial/doc/bnbbf.html under the heading: External Binding Customization Files.

Correct structure for binding xml:

<jxb:bindings schemaLocation = "xs:anyURI">
   <jxb:bindings node = "xs:string">
      <binding declaration>
   <jxb:bindings>
</jxb:bindings>

2 comments:

  1. Turned out that the upgrade of the maven plugin wasn't necessary to solve this problem, but still a good idea, since 1.10 is SO old (2007).

    ReplyDelete
  2. I noticed that they fixed the generated plugin xml in Netbeans 7.2: http://netbeans.org/bugzilla/show_bug.cgi?id=210457

    ReplyDelete