java wsimport rename/different ObjectFactory.java

zmeda picture zmeda · May 30, 2011 · Viewed 8.8k times · Source

I'm having problem with wsimport. In one of my wsdl which has to be wsimported I have a complexType with name "objectFactory". Is there any way to tell command wsimport to create while importing different class for maintaining JAXB connections such is ObjectFactory.java. In other words can I tell wsimport instead of creating ObjectFactory.java some custom class like MyCustomFactory.java?

Is it possible to customize mapping in such a way that complexType name="objectFactory" would map to object with different name like MyObjectFactory.java?

Thx

Answer

Joachim Sauer picture Joachim Sauer · May 31, 2011

JAX-WS (of which wsimport is a part) uses JAXB for generating the XML binding files (and for doing the actual binding). So you'll want to check out this documentation on customizing JAXB bindings. It applies just as well to your case.

In your case you'd use something like this:

<xsd:complexType name="objectFactory">
  <xsd:annotation>
  <xsd:appinfo>
     <jxb:class name="MyObjectFactory" />
  </xsd:appinfo>
  </xsd:annotation>
  <!-- ... rest of your specification ... ->
</xsd:complexType>

This example is for inline customization in your XML Schema/WSDL. You can also provide this information as external configuration.