gpt4 book ai didi

java - 如何使用 JAXWS/JAXB 重命名参数

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:20:08 25 4
gpt4 key购买 nike

我使用 CXF(2.2.3) 编译 Amazon Web Service WSDL ( http://s3.amazonaws.com/ec2-downloads/2009-07-15.ec2.wsdl )

但出现如下错误。

Parameter: snapshotSet already exists for method describeSnapshots but of type com.amazonaws.ec2.doc._2009_07_15.DescribeSnapshotsSetType instead of com.amazonaws.ec2.doc._2009_07_15.DescribeSnapshotsSetResponseType. Use a JAXWS/JAXB binding customization to rename the parameter.

冲突是由于以下数据类型引起的:

<xs:complexType name="DescribeSnapshotsType">
<xs:sequence>
<xs:element name="snapshotSet" type="tns:DescribeSnapshotsSetType"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="DescribeSnapshotsResponseType">
<xs:sequence>
<xs:element name="requestId" type="xs:string"/>
<xs:element name="snapshotSet" type="tns:DescribeSnapshotsSetResponseType"/>
</xs:sequence>
</xs:complexType>

我创建了一个绑定(bind)文件试图解决这个问题......但它没有完成工作

   <jaxws:bindings
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
wsdlLocation="EC2_2009-07-15.wsdl"
xmlns="http://java.sun.com/xml/ns/jaxws"
xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
xmlns:jaxws="http://java.sun.com/xml/ns/jaxws">

<enableWrapperStyle>false</enableWrapperStyle>
<jaxws:bindings node="wsdl:definitions/wsdl:types/xs:schema[@targetNamespace='http://ec2.amazonaws.com/doc/2009-07-15/']">
<jxb:bindings node="xs:complexType[@name='tns:DescribeSnapshotsType']//xs:element[@name='snapshotSet']">
<jxb:property name="snapshotRequestSet"/>
</jxb:bindings>
<jxb:bindings node="xs:complexType[@name='DescribeSnapshotsResponseType']//xs:element[@name='snapshotSet']">
<jxb:property name="snapshotResponseSet"/>
</jxb:bindings>
</jaxws:bindings>
</jaxws:bindings>

我使用的命令如下所示

<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/EC2_2009-07-15.wsdl</wsdl>
<extraargs>
<extraarg>-b</extraarg>
<extraarg>${basedir}/src/main/resources/wsdl/Bindings_EC2_2009-07-15.xml</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>

我的代码有什么问题????

您可以使用 svn 查看我的项目....svn公司http://shrimpysprojects.googlecode.com/svn/trunk/smartcrc/AWSAgent/

最佳答案

如@PascalThivent 所述,CXF 有一个参数 -autoNameResolution,您应该尝试使用它。 CXF遇到这个的时候给的message,可惜没有提到。

关于java - 如何使用 JAXWS/JAXB 重命名参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1477436/

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