Java – wsimport: adding Binding when the XSD is embedded in WSDL

javawsdlwsimportxsd

I'm trying to generate some java code from the following WSDL: http://www.ebi.ac.uk/Tools/services/soap/emboss_needle?wsdl

$ wsimport -keep  "http://www.ebi.ac.uk/Tools/services/soap/emboss_needle?wsdl"

however it generates some JAXBElement<String> instead of String. So I've tried to use a xjb binding as it is described here: Get rid of JAXBElement in classes generated by wsimport called from ant

<jxb:bindings xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="2.0">
  <jxb:bindings>
    <jxb:globalbindings generateelementproperty="false">
      <jxb:javatype name="java.lang.String" xmltype="xs:string"/>
    </jxb:globalbindings>
  </jxb:bindings>
</jxb:bindings>

but wsimport raises an exception:

$ wsimport -keep -b binding.xjb "http://www.ebi.ac.uk/Tools/services/soap/emboss_needle?wsdl"
[ERROR] The "jxb:globalbindings" customization is not associated with any schema element.
  line 6 of file:/home/lindenb/tmp/WS/biostar14996.xjb

The XSD schema is embedded in the WSDL document. What URI should I give for the jxb:schemaLocation ? How can I fix that problem ?

Thanks,

P.

Best Answer

Eventually I ended up with:

<jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" wsdlLocation="YOUR_WSDL_LOCATION">
    <jxb:globalBindings generateElementProperty="false"/> 
</jxb:bindings>
Related Topic