Wednesday, October 09, 2013

Simple WS client using CXF for .NET WS server

A long time ago I figured out this incompatibility, the matter is than when consuming a SOAP web service produced by a .NET server, the following exception used to happen:

undefined element declaration 's:schema'

so, searching again a lot, I've found the solution; so using a CXF maven plugin to build the client, will simply look like this:

<execution>
                        <id>generate-sources</id>
                        <phase>generate-sources</phase>
                        <configuration>
                            <wsdloptions>
                                <wsdloption>
                                    <wsdl>
                                        ../path/to/wsdl
                                    </wsdl>

                                    <extraargs>
                                        <extraarg>-b</extraarg>
                                        <extraarg>http://www.w3.org/2001/XMLSchema.xsd</extraarg>
                                        ... OTHER EXTRAARGS ...
                                    </extraargs>
                                </wsdloption>
                            </wsdloptions>
                        </configuration>
                        <goals>
                            <goal>wsdl2java</goal>
                        </goals>
                    </execution>


Simply add those two extraarg elements to the POM, and that's all. Of course using those same parameters when using CXF via command line will work fine.