Combining JAXB and JAXWS for an Imported XML Schema

How can I specify JAXB binding for imported XSD in WSDL when using wsimport?

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

<?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?

+2
source share
3 answers

I did something similar many years 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 type you use here. Hope it fixes your question.

+1
source

- XPath jxb: binding, . , XPath , DOM.

, , XSD. , XSD, . -, , / XSD .

+1

, , , Google , , .


JAXB XSD WSDL - ... !

:

MyXSD.xsd

<xsd:schema targetNamespace="whatever"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <xs:complexType name="ThingThatNeedsToBeBound">
        <!-- Whatever this is made of -->
    </xs:complexType>
</xsd:schema>

, xsd ( wsdl ), , , "ThingThatNeedsToBeBound" :

customBindings.xml

<jaxb:bindings schemaLocation="Path/To/MyXSD.xsd" node="/xs:schema/xs:complexType[@name='ThingThatNeedsToBeBound']">
    <!-- your custom binding -->
</jaxb:bindings>

, , , schemaLocation, , -.

, .


: http://www.oracle.com/technetwork/articles/grid/jax-ws-jaxb-customization-082750.html

(: , , , , , , , , !)

+1

All Articles