I have a WSDL file weatherservice.wsdl
and I am trying to generate binding for this WSDL using xjc
. How do I do this using xjc?
I did not find any command line args to do it from xjc. xjc -p com -wsdl weatherservice.wsdl
Generally we create a bindings file with .xjb
extension to resolve any conflicts in the WSDL or schema. For example if two elements have the same name and you want to distinguish between them you can rename one by specifying it the bindings file.
Here is an example:
<jaxb:bindings
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc"
version="2.1">
<jaxb:globalBindings generateIsSetMethod="true" fixedAttributeAsConstantProperty="true">
<xjc:serializable uid="1" />
</jaxb:globalBindings>
<jaxb:bindings schemaLocation="abcd.xsd">
<jaxb:bindings node="//xs:element[@name='Event']/xs:simpleType">
<jaxb:typesafeEnumClass name="EventEnumType" />
</jaxb:bindings>
</jaxb:bindings>
</jaxb:bindings>
Try using this simple binding. Save it next to the WSDL and tell XJC to use that.
<bindings version="2.0"
xmlns="http://java.sun.com/xml/ns/jaxb"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
>
<globalBindings>
<xjc:simple/>
</globalBindings>
</bindings>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With