Inject annotation with xjc and custom binding file

970 Views Asked by At

Well, I've got this external (and old) WSDL structured like this:

<wsdl:definitions xmlns:s="http://www.w3.org/2001/XMLSchema"
    xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
    xmlns:http="http://schemas.xmlsoap.org/wsdl/http/"
    xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/"
    xmlns:tns="...custom namespace..."
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"
    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
    targetNamespace="...custom namespace..."
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
    <wsdl:types>
        <s:schema elementFormDefault="qualified" targetNamespace="...custom namespace...">
            <s:element name="...">
            </s:element>
            <s:element name="...">
            </s:element>
            <s:complexType name="CustomClassName">
            ...

I'm creating Java classes from this WSDL with xjc.

The request I'm using from this WSDL responds with plain XML beginning with CustomClassName, but this class is not annotated with XMLRootElement.

When I manually add this annotation to this class, my code works just fine.

But I want to add the annotation by using a custom binding file when calling xjc, and a.t.m. I can't get this to work. My current custom binding file looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxb:bindings 
    xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:s="http://www.w3.org/2001/XMLSchema" 
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xmlns:annox="http://annox.dev.java.net"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xsi:schemaLocation="http://java.sun.com/xml/ns/jaxb http://java.sun.com/xml/ns/jaxb/bindingschema_2_0.xsd"
    jaxb:extensionBindingPrefixes="xjc annox" version="2.1">

    <jaxb:bindings schemaLocation="...wsdl filename..." node="//s:schema">
        <jaxb:bindings node="s:complexType[@name='CustomClassName']">
            <annox:annotate>
                <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" />
            </annox:annotate>
        </jaxb:bindings>
    </jaxb:bindings>
</jaxb:bindings>

(I've tried different syntaxes I found but the class is still not annotated.)

Where's my mistake?

0

There are 0 best solutions below