gpt4 book ai didi

java - 如何在 stub 生成期间重命名 WSDL 中的复杂类型

转载 作者:行者123 更新时间:2023-12-01 14:12:28 25 4
gpt4 key购买 nike

我正在使用 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">…</xs:complexType>
....
</types>
....
</definitions>

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

<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

我查看了以下帖子here , here还有一些引用文献reference 1reference 2

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

最佳答案

喘口气后,我再次查看this解决了这个问题。 .

所以我的绑定(bind)结果是:

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

关于java - 如何在 stub 生成期间重命名 WSDL 中的复杂类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18390750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com