how to Use JAXWS/JAXB rename the parameter

Posted by shrimpy on Stack Overflow See other posts from Stack Overflow or by shrimpy
Published on 2009-09-25T13:57:09Z Indexed on 2010/04/16 1:53 UTC
Read the original article Hit count: 761

Filed under:
|
|

I use CXF(2.2.3) to compile the Amazon Web Service WSDL (http://s3.amazonaws.com/ec2-downloads/2009-07-15.ec2.wsdl)

But got error as below.

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.

The conflict was due to the data type show below:

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

I create a binding file try to address the issue...but it didn`t do the job

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

And the command i used, was like below

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

What is wrong with my code????

And you can check out my project by using svn.... svn co http://shrimpysprojects.googlecode.com/svn/trunk/smartcrc/AWSAgent/

© Stack Overflow or respective owner

Related posts about jaxws

Related posts about jaxb