0

我正在使用 wsimport

我需要重命名一个 xs:complextype name=Address 以防止一些构建冲突。

这是 WSDL 的一个片段:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:ns="http://fedex.com/ws/rate/v13" xmlns:s1="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="http://fedex.com/ws/rate/v13" name="RateServiceDefinitions">
  <types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://fedex.com/ws/rate/v13">
      <xs:complexType name="Address">…&lt;/xs:complexType>
    ....
   </types>
   ....
</definitions>

我正在使用外部绑定文件:

<jxb:bindings 
    xmlns="http://schemas.xmlsoap.org/wsdl/"
    xmlns:ns="http://fedex.com/ws/rate/v13"
    xmlns:s1="http://schemas.xmlsoap.org/wsdl/soap/"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.1"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    >

    <jxb:globalBindings>
        <jxb:javaType name="java.util.Calendar" xmlType="xs:dateTime" parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime" printMethod="javax.xml.bind.DatatypeConverter.printDateTime" />
    </jxb:globalBindings>
   <jxb:bindings node="definitions/types/xs:schema/xs:complexType[@name='Address']/xs:complexType">
        <!-- change java method name from addNumbers() to add() -->
        <jxb:class name="FedExAddress"/>
    </jxb:bindings>
</jxb:bindings>

当我执行构建时,我收到以下消息:

[wsimport] [ERROR] XPath evaluation of "definitions/types/xs:schema/xs:complexType[@name='Address']/xs:complexType" results in empty target node
 [wsimport]   line 14 of file:/Users/davidboyd/projects/heritage/hybris/bin/custom/cpdeliveryservice/fedex_binding.xml

我在这里这里和一些参考文献以及参考文献 1参考文献 2中查看了以下帖子

但不明白为什么这不起作用。

4

1 回答 1

1

稍作休息后,我能够解决这个问题,我再看看这个

所以我得到的绑定是:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<jaxws:bindings 
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
    xmlns:jaxws="http://java.sun.com/xml/ns/jaxws"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb" jxb:version="2.1"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
    wsdlLocation="/RateService_v13.wsdl"
    >

    <enableWrapperStyle>true</enableWrapperStyle>
    <enableAsyncMapping>false</enableAsyncMapping>

    <!-- convert all xs:dateTime to java type of Calendar -->
    <jaxws:globalBindings>
        <jxb:javaType name="java.util.Calendar" xmlType="xs:dateTime" parseMethod="javax.xml.bind.DatatypeConverter.parseDateTime" printMethod="javax.xml.bind.DatatypeConverter.printDateTime" />
    </jaxws:globalBindings>

    <!-- Rename Address to FedExAddress -->
    <jaxws:bindings node="//xs:complexType[@name='Address']">
        <jxb:class name="FedExAddress"/>
    </jaxws:bindings>

</jaxws:bindings>
于 2013-08-23T03:01:10.510 回答