This discussion is archived
1 Reply Latest reply: Jan 18, 2012 6:56 AM by 871939 RSS

JAX-WS JAXB.  wsimport and an external global bindings file

871939 Newbie
Currently Being Moderated
Hi all,

I am having some trouble attempting to create an external bindings file for JAXB to be used through wsimport. The problem I have is when JAXB runs over the xml schema it has a problem with items in the xml being derived by restriction and extension.

Having searched around people have suggested using xjc:treatRestrictionLikeNewType to resolve this problem. However I am struggling to use it correctly!

I need to use it in an external file as I cannot modify the schema and there are many xsd files in the schema so really I want to be able to set it up as a global binding. While there are several pages from the oracle site alone offering help they don't seem to describe such a case and the examples involve jaxb version 1.0 which if I have understood from reading around the web did not support global bindings - each xsd had to be set up will all the required bindings.

The xjb I currently have looks something like this:
<bindings xmlns="http://java.sun.com/xml/ns/jaxb"
          xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
          xmlns:xs="http://www.w3.org/2001/XMLSchema"
          xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc"
          xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
          version="2.1">

    <xs:annotation><xs:appinfo>
       <jaxb:globalBindings>
          <xjc:treatRestrictionLikeNewType/>
       </jaxb:globalBindings>
    </xs:appinfo></xs:annotation>
</bindings>
This gives me a message that xs:annotation is not associated with any schema element.

I don't know if I'm close or if this is horribly wrong. Any suggestions are welcome.

Thanks,

Dan.
  • 1. Re: JAX-WS JAXB.  wsimport and an external global bindings file
    871939 Newbie
    Currently Being Moderated
    Updating myself....

    I now believe that the
    <xs:annotation><xs:appinfo>
    is for when you are modifying the schema so that you don't need the external bindings file. As a result I have modified my xjb as follows:
    <bindings xmlns="http://java.sun.com/xml/ns/jaxb"
              xmlns:xsi="http://www.w3.org/2000/10/XMLSchema-instance"
              xmlns:xs="http://www.w3.org/2001/XMLSchema"
              xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc" jaxb:extensionBindingPrefixes="xjc"
              xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
              version="2.1">
     
           <jaxb:globalBindings>
              <xjc:treatRestrictionLikeNewType/>
           </jaxb:globalBindings>
     
    </bindings>
    This removes the error that xs:annotation is not associated with any schema element but results in the same error -
    [ERROR] Base complex type "A" is derived by restriction, while this complex type "B" is derived by extension. This is not currently handled by XJC, but we are seeking input on this issue. Please report this to the JAXB team.
    So it seems that my bindings file is either being ignored by wsimport or is still just plain wrong. Any suggestions.

    Thanks

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points