Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate *.xjb file from WSDL?

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

like image 426
Tito Avatar asked Mar 26 '15 23:03

Tito


Video Answer


2 Answers

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>
like image 132
Surendra Poranki Avatar answered Sep 18 '22 17:09

Surendra Poranki


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>
like image 40
anjan Avatar answered Sep 18 '22 17:09

anjan