Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating web service proxy classes using wsdl2java/Apache CXF

I'm trying to generate a web service proxy using the wsdl2java tool that comes with Apache CXF. The generation itself seems to go just fine, but there are some errors in the generated files, a non-existing constructor is called.

The file offers a solution:

//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
//API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
//compliant code instead.

So I set out to download and install the 2.2 version of the JAX-WS Api. I found the following installation manual explaining how to endorse these new files: http://dcx.sybase.com/1200/en/dbprogramming/httpserver-jaxws-lesson-two.html I followed every step of this guide, removed the old generated files and generated new ones, but the problem persists.

Any tips and/or tricks? (now of course, I'm using the -frontend jaxws21 flag to generate the proxy, but still).

like image 723
fuaaark Avatar asked May 04 '12 11:05

fuaaark


1 Answers

<defaultOptions>
    <frontEnd>jaxws21</frontEnd>
</defaultOptions>

This is how I solved the issue using maven:

        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>2.5.2</version>
            <executions>
                <execution>
                    <id>generate-sources2</id>
                    <configuration>
                        <sourceRoot>${basedir}/target/generated-sources/cxf</sourceRoot>
                        <defaultOptions>
                            <frontEnd>jaxws21</frontEnd>
                        </defaultOptions>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>...</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

EDIT: I've found another way to solve this using maven and cxf version 2.7.3. Add these libraries in your dependencies. You now dont have to use the jaxws21 option:

    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.2.9</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.7</version>
    </dependency>
like image 74
Jan-Terje Sørensen Avatar answered Nov 02 '22 16:11

Jan-Terje Sørensen