为HR-XML PositionOpening WSDL生成Web服务代理客户端

时间:2011-06-21 04:58:21

标签: java web-services code-generation jax-ws axis2

我正在尝试使用Position Opening WSDL提供的HR-XML Consortium的Apache Axis2生成Java Web服务代理客户端。我正在使用wsdl2java命令行工具来生成代理客户端。

命令:

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

最后,我尝试通过调用ant jar.all将生成的类转换为JAR。不幸的是,它无法正确编译并抛出一些错误。我不知道原因是什么。有超过100个错误,但我在下面显示了出现在顶部的前3个错误。

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]             ^

有人可以对此有所了解吗?我的目的是将此Position Opening WSDL转换为JAR,以便我可以直接在我的应用程序中使用/调用函数。

修改

与此同时,我甚至尝试使用JAX-WS的wsimport工具,但它在命令本身失败了。

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

2 个答案:

答案 0 :(得分:1)

我已经设法找到JAX-WS的wsimport工具失败的原因。从HR-XML and Java documentation开始,原因及其解决方法如下所示:

  

JAX-WS无法处理HR-XML Consortium提供的提供的HR-XML WSDL和XSD。模式或Web服务定义没有错误,但JAX处理引擎使用的模式和目录结构不支持。这是JAX-WS的限制,希望在将来的版本中得到纠正。要解决这些问题,必须进行以下更改。

     

文件中的属性类型   org_openapplications_platform \ 1_1 \ COMMON \ OAGi的\组件\ components.xsd   必须重命名才能生成代码。

然而,在尝试使用ant构建JAR时,我仍然没有任何想法/回答为什么它与Apache Axis2失败。

答案 1 :(得分:0)

我能够通过在调用wsimport" wsimport -b binding.xml ..."

中指定此绑定文件来使其工作。

(请注意,我在本地设置了模式,因此必须在下面的xml中更改Components.xsd的schemaLocation)

<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>