Search code examples
wsdlxsdjaxbjax-wswsimport

Combine JAXB and JAXWS for an imported XML Schema


How can I specify a JAXB Binding for an imported XSD within a WSDL when using wsimport?

I tried following binding, which causes the error "XPath evaluation of //xs:element[@name='isFoobar'] results in an empty target node".

<?xml version="1.0" encoding="UTF-8"?>
<jaxws:bindings xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" wsdlLocation="example.wsdl"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">
    <jaxws:bindings node="wsdl:definitions">
        <jaxws:bindings node="wsdl:types" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb">
            <jaxws:bindings
                node="//xs:schema[@targetNamespace='http://www.example.org/']">
                <jaxb:globalBindings>
                    <xjc:serializable uid="10000001" />
                </jaxb:globalBindings>
                <jaxb:bindings
                    node="//xs:element[@name='isFoobar']">
                    <jaxb:typesafeEnumClass name="IsFoobar">
                        <jaxb:typesafeEnumMember value="01" name="TRUE" />
                        <jaxb:typesafeEnumMember value="02" name="FALSE" />
                    </jaxb:typesafeEnumClass>
                </jaxb:bindings>
            </jaxws:bindings>
        </jaxws:bindings>
    </jaxws:bindings>
</jaxws:bindings>

Any ideas?


Solution

  • I did something similar ages ago, I think you need to specify the node to select with XPath as follows:

    //xs:element[@name='isFoobar']/xs:complexType
    

    Or replace xs:complexType with whatever kind of type you are using here. Hopefully it will fix your probelm.