Java, i webservice, cxf e maven: creare la classi per il client partendo dal wsdl
Il plugin da utilizzare lo fornisce direttamente la Apache, ed è il seguente:
<groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> |
Creare un progetto maven vuoto con questa struttura:
prova - scr -resources -MioWsdl.wsdl pom.xml |
Il file pom.xml, in versione minimale è il seguente:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <name>Pippo</name> <groupId>it.nicola</groupId> <artifactId>pippo</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <dependencies></dependencies> <build> <plugins> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>2.5.1</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> <plugin> <groupId>org.apache.cxf</groupId> <artifactId>cxf-codegen-plugin</artifactId> <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/MioWsdl.wsdl</wsdl> </wsdlOption> </wsdlOptions> </configuration> <goals> <goal>wsdl2java</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> |
a questo punto con
mvn clean compile |
nella target/generated vengono creati tutti i file necessari al client.
Questo è solo un punto di partenza, per una configurazione più dettagliata questa è la pagina da leggere: http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html
Leave a Reply