Pierre
Pierre

Reputation: 35306

wsimport: adding Binding when the XSD is embedded in WSDL?

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.

Upvotes: 3

Views: 11512

Answers (3)

vlad
vlad

Reputation: 31

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>

Upvotes: 3

Hamish McWilliam
Hamish McWilliam

Reputation: 11

The EMBL-EBI's EMBOSS needle service (http://www.ebi.ac.uk/Tools/services/soap/emboss_needle?wsdl), and most of their other analysis tool services (see http://www.ebi.ac.uk/Tools/webservices/) allow for submission parameters to have three states:

  1. Explicit value
  2. Null value
  3. To be omitted

This provides compatibility with a wide range of SOAP tool-kits, some of which assume only one or two out of these three behaviors.

An unfortunate side-effect of this is that tool-kits such as JAX-WS, which understand that there are three states, need to use a more complex representation to handle this. Thus the JAXBElement classes are required. EMBL-EBI provides sample clients with source code using JAX-WS for their InterProScan (SOAP) and NCBI BLAST (SOAP) services, which use the same pattern for their parameters (see http://www.ebi.ac.uk/Tools/webservices/tutorials/06_programming/java/soap/jax-ws).

Upvotes: 1

Petru Gardea
Petru Gardea

Reputation: 21658

I believe your problem is similar to this post; there are links pointing you to the documentation, as well as the solution; basically, when you bind against WSDL files, you need a different top level element; the accepted response gives you the command line as well.

Upvotes: 0

Related Questions