2

I'm trying to use CXF to consume a SOAP web service. The issue I'm having is that JAXB throws up when trying to consume the WSDL. The part it doesn't like is:

<xs:sequence>
    <xs:any minOccurs="0" maxOccurs="unbounded" namespace="http://www.w3.org/2001/XMLSchema" processContents="lax"/>
    <xs:any minOccurs="1" namespace="urn:schemas-microsoft-com:xml-diffgram-v1" processContents="lax"/>
</xs:sequence>

It gives the error:

Property "Any" is already defined. Use <jaxb:property> to resolve this conflict.

From reading other questions such as this one, it is possible to define an external binding file to resolve the error. The issue is I'm not sure how to do this within the cxf-codegen-plugin. Can anyone point me at how to do it?

Here is the relevant part of my pom.xml

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.1.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/DataGeneratorInbox.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Community
  • 1
  • 1
Tom Squires
  • 8,848
  • 12
  • 46
  • 72

1 Answers1

3

The issue is I'm not sure how to do this within the cxf-codegen-plugin. Can anyone point me at how to do it?

You can add binding files in the cxf-codegen-plugin with the <bindingFiles> attribute, like this:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.1.2</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/DataGeneratorInbox.wsdl</wsdl>
                    </wsdlOption>
                </wsdlOptions>
                <bindingFiles>
                    <bindingFile><!-- path to your file --></bindingFile>
                </bindingFiles>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Tunaki
  • 132,869
  • 46
  • 340
  • 423
  • @Tom Squires, I am also facing the same issue. I tried to write the binding file but still facing some issues. Can any one please provide the binding file for this.? – Amar Oct 05 '16 at 11:23
  • @Amar You're not commenting to the right person, but take a look [at this question](http://stackoverflow.com/questions/4394134/jaxb-property-value-is-already-defined-use-jaxbproperty-to-resolve-this) for the binding file. – Tunaki Oct 05 '16 at 11:32