3

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

但得到如下错误。

参数:方法 describeSnapshots 的 snapshotSet 已存在,但类型为 com.amazonaws.ec2.doc._2009_07_15.DescribeSnapshotsSetType 而不是 com.amazonaws.ec2.doc._2009_07_15.DescribeSnapshotsSetResponseType。使用 JAXWS/JAXB 绑定定制来重命名参数。

冲突是由于数据类型显示如下:

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

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

   <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 co http://shrimpysprojects.googlecode.com/svn/trunk/smartcrc/AWSAgent/

4

4 回答 4

3

正如@PascalThivent 提到的,CXF 有一个参数 -autoNameResolution,您应该尝试使用它。CXF遇到这个时给出的消息,可惜没有提及。

于 2015-02-11T15:54:00.813 回答
1

在您的绑定文件中,您使用xs:..... 但名称空间http://www.w3.org/2001/XMLSchema的引用,xds所以如果它不起作用,请尝试将引用重命名xsdxs (顺便感谢您的解决方案,它有效)

于 2010-08-31T08:17:46.827 回答
0

这部分

<enableWrapperStyle>false</enableWrapperStyle>

应该

<jaxws:enableWrapperStyle>false</jaxws:enableWrapperStyle>

于 2010-04-16T01:47:57.880 回答
0

对于尝试此操作的任何人:我总结了所有更正:

<jaxws:bindings
xmlns:xs="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">

<jaxws:enableWrapperStyle>false</jaxws: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>

于 2018-10-09T14:38:06.523 回答