In einer serviceorientierten Architektur Landschaft, braucht man öfters einen Client zu einer bestehenden WSDL.
Das Zusammenspiel von Maven, Spring und CXF erleichtert einem diese Unternehmen ungemein.
Hier einmal ein Auszug aus der pom.xmleines generierten Clients:
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-core</artifactId>
<version>${cxf.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-activation_1.1_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>wsdl4j</groupId>
<artifactId>wsdl4j</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-activation_1.1_spec</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-common-utilities</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${spring.version}</version>
</dependency>
.....
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.0.6</version>
<executions>
<execution>
<id>generate-wsdl-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${basedir}/target/generated-sources/src</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>src/main/wsdl/hello.wsdl</wsdl>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
.....
</plugins>
</build>
Cxf- und Spring-Abhängigkeiten werden ergänzt, sowie das cxf-codegen-plugin wird benutzt um aus der wsdl Klassen zu generieren.
In der Spring Konfigurationsdatei ist nun lediglich ein jaxws namespace einzutragen und das entsprechende jaxws:client tag zu benutzen.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">
<jaxws:client id="localClient"
serviceClass="com.example.HelloWorldPortType"
address="http://localhost:8080/Hello"/>
.....
Schneller kann man meiner meinung nach von einer WSDL nicht zu einem Client gelangen ....
Ressourcen:

neueste Version des code-gen-plugin ist übrigens 2.2 ;-)