【问题标题】:How to rename complex type in a WSDL during stub generation如何在存根生成期间重命名 WSDL 中的复杂类型
【发布时间】:2013-08-22 21:01:40
【问题描述】:

我正在使用 wsimport

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

这是 WSDL 的 sn-p:

<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">…</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

我查看了以下帖子herehere 以及一些参考资料以及reference 1reference 2

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

【问题讨论】:

    标签: java binding jaxb wsdl wsimport


    【解决方案1】:

    稍作休息后,我再次查看this 解决了这个问题。

    所以我得到的绑定是:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-08
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多