【问题标题】:Generating web service proxy client for HR-XML PositionOpening WSDL为 HR-XML PositionOpening WSDL 生成 Web 服务代理客户端
【发布时间】:2011-09-19 05:11:15
【问题描述】:

我正在尝试为HR-XML Consortium 提供的Position Opening WSDL 使用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

【问题讨论】:

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


    【解决方案1】:

    我已经设法找到了使用 JAX-WS 的 wsimport 工具失败的原因。来自HR-XML and Java documentation,原因及其解决方法解释如下:

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

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

    但是,我仍然不知道为什么在尝试使用 ant 构建 JAR 时使用 Apache Axis2 失败。

    【讨论】:

      【解决方案2】:

      我可以通过在调用 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>
      

      【讨论】:

        猜你喜欢
        • 2013-01-02
        • 2015-09-09
        • 1970-01-01
        • 2014-03-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多