July 01, 2009

WSDL-first CXF-Client mit Maven und Spring

« Java RSS Example with Rome | Main | Configure Digest, Basic authentification or SSL (web.xml) »

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:

Posted by peter.grund at 3:47 PM in Maven

 

[Trackback URL for this entry]

Comment: Peter at Do, 2 Jul 9:44 AM

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

Comment: Debt Settlement Help at So, 13 Sep 10:06 PM

Great headline. If your cookie has a bite-sized action and your reader completes the action, I think two things happen. Their self-confidence goes up (which feels good) and their trust in you increases.

Comment: WP Themes at Mi, 23 Dez 3:58 PM

I over recall the collection is good and on the point. This send really helped me in my assignment.

Comment: WP Themes at Do, 24 Dez 12:06 PM

I deliberate on the collection is good and on the point. This post indeed helped me in my assignment.

Comment: Vigrx at Sa, 26 Dez 1:52 AM

Closely I believe that this brief is something which need more attention of your readers.

Comment: Vigrx at Sa, 26 Dez 5:37 AM

Well I believe that this brief is something which necessity more attention of your readers.

Your comment:

(not displayed)
 
 
 

Live Comment Preview:

 
« July »
SunMonTueWedThuFriSat
   1234
567891011
12131415161718
19202122232425
262728293031