2

I'm customizing JAXB beans generated by an WSDL file with jaxws-maven-plugin. To customize them I'm using a binding file.

Basically I want:

  • Prevent the generation of JAXBElement
  • Customize some element names

My bindings file is:

<jaxws:bindings version="2.1"
           xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
           xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
           xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
           xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">

<!--Element 1-->
<jaxb:globalBindings generateElementProperty="false">
    <xjc:simple/>
</jaxb:globalBindings>

 <!--Element 2-->
<jaxb:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema" node="//xs:complexType[@name='WorkDocuments']/xs:choice">
    <jaxb:property name="documents"/>
</jaxb:bindings>

The problem is that if I use jaxws:bindings as root element the Element 1 doesn't works and JAXBElement are generated

And if I use jaxb:bindings as root element then Element 1 works but Element 2 doesn't as the xpath expressions doesn't match any element.

How can I correct the binding file to get the two elements working at same time?

lujop
  • 13,504
  • 9
  • 62
  • 95

1 Answers1

2

I found a solution that is use <jaxws:bindings> as root element and then put the globalBindings inside a jaxws:bindings:

That is:

<jaxws:bindings version="2.1"
            xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
            xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
            xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
            xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">

<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='yourNamespace']">
    <jaxb:globalBindings generateElementProperty="false">
    </jaxb:globalBindings>       
</jaxws:bindings>

lujop
  • 13,504
  • 9
  • 62
  • 95