1

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?

Gunnar
  • 383
  • 4
  • 18
  • Seems like customizations don't get attached to WSDL. I recall there were a couple of questions about the same problem. – lexicore Jul 31 '15 at 19:29
  • Since it's not a solution for this question I'm posting it as a comment: I've found another way in these answers: http://stackoverflow.com/questions/819720/no-xmlrootelement-generated-by-jaxb/2172942#2172942 (no XMLRootElement annotation needed when working with JAXBElement and XMLStreamReader) – Gunnar Aug 03 '15 at 05:32

0 Answers0