简体   繁体   中英

Generating web service proxy client for HR-XML PositionOpening WSDL

I'm trying to generate Java web service proxy client using Apache Axis2 for Position Opening WSDL provided by HR-XML Consortium . I'm using wsdl2java command-line tool to generate proxy client.

Command:

wsdl2java -uri http://ns.hr-xml.org/schemas/org_hr-xml/3_1_1/Services/Web_Services/WSDL/PositionOpening.wsdl -d adb -o hrxml-positionopening

Finally, I then try to convert the generated classes into JAR by calling ant jar.all . Unfortunately, it is failing to compile properly and throwing some errors. I don't know what the reasons are. There are more than 100 errors, but I have shown below the first 3 errors that appear at the top.

E:\axis2-1.5.4\bin\hrxml-positionopening>ant jar.all
Buildfile: build.xml

init:

pre.compile.test:
     [echo] Stax Availability= true
     [echo] Axis2 Availability= true

compile.src:
    [javac] Compiling 3 source files to E:\axis2-1.5.4\bin\hrxml-positionopening\build\classes
    [javac] E:\axis2-1.5.4\bin\hrxml-positionopening\src\org\hr_xml\www\_3\ws\PositionOpening_ServiceStub.java:315862: 'else' without 'if'
    [javac]                                         else
    [javac]                                         ^
    [javac] E:\axis2-1.5.4\bin\hrxml-positionopening\src\org\hr_xml\www\_3\ws\PositionOpening_ServiceStub.java:315964: 'else' without 'if'
    [javac]                              } else {
    [javac]                                ^
    [javac] E:\axis2-1.5.4\bin\hrxml-positionopening\src\org\hr_xml\www\_3\ws\PositionOpening_ServiceStub.java:315718: 'try' without 'catch' or 'finally'
    [javac]             try {
    [javac]             ^

Can somebody throw some light on this? My purpose is to convert this Position Opening WSDL into a JAR, so that I can use/call the functions directly from within my application.

EDIT:

Meantime, I even tried with wsimport tool of JAX-WS, but it is failing at the command itself.

E:\jdk1.6.0\bin>wsimport.exe -d hrxml-positionopening http://ns.hr-xml.org/schemas/org_hr-xml/3_1_1/Services/Web_Services/WSDL/PositionOpening.wsdl
error: Property "Type" is already defined.
  line 1473 of http://ns.hr-xml.org/schemas/org_openapplications_platform/1_1/Common/OAGi/Components/Components.xsd
error: The following location is relevant to the above error
  line 1480 of http://ns.hr-xml.org/schemas/org_openapplications_platform/1_1/Common/OAGi/Components/Components.xsd
error: com.sun.istack.internal.SAXParseException2: The following location is relevant to the above error

I've managed to find the reason why it was failing with wsimport tool of JAX-WS. From HR-XML and Java documentation , reason and its work around is explained as shown below:

JAX‐WS cannot process the supplied HR‐XML WSDLs and XSDs as supplied by the HR‐XML Consortium. There are no errors with the schemas or web service definitions, but the patterns and directory structures employed are not supported by the JAX processing engine. This is a limitation of JAX‐WS that will hopefully be rectified in future versions. To work around these issues, the following changes must be made.

The attribute type in file org_openapplications_platform\\1_1\\Common\\OAGi\\Components\\components.xsd must be renamed for code generation.

However, still I don't have any idea/answer on why it was failing with Apache Axis2 while trying to build JAR using ant.

I was able to make it work by specifying this binding file in my call to wsimport "wsimport -b binding.xml ..."

(Note that I had the schemas on my local so the schemaLocation for Components.xsd would have to be changed in the xml below)

<jxb:bindings 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    version="2.1">

    <!-- Raise theEnumMemberSizeCap limit -->
    <jxb:bindings>
        <jxb:globalBindings typesafeEnumMaxMembers="2000"/>
    </jxb:bindings>


    <jxb:bindings schemaLocation="DataQuery_wsdl/Components.xsd" version="1.0">
        <!-- Customise the package name -->
        <!--<schemaBindings>
            <package name="com.example.schema"/>
        </schemaBindings>-->

        <!-- rename the value element -->
        <jxb:bindings node="//xsd:complexType[@name='ContactType']">
            <jxb:bindings node=".//xsd:attribute[@name='type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='DocumentReferenceType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='ClassificationType']">
            <jxb:bindings node=".//xsd:attribute[@name='type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='ImageAttachmentType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='OpenAttachmentType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='SpecificationType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='EventType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='QualifiedAmountType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='TermABIEType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='DimensionABIEType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='CurrencyExchangeBaseType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='ProjectABIEType']">
            <jxb:bindings node=".//xsd:attribute[@name='type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='AddressBaseType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='TaxABIEType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='AllowanceChargeABIEType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

        <jxb:bindings node="//xsd:complexType[@name='LocationABIEType']">
            <jxb:bindings node=".//xsd:element[@ref='Type']">
                <jxb:property name="TypeAttribute"/>
            </jxb:bindings>
        </jxb:bindings>

    </jxb:bindings>   


</jxb:bindings>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM