web-services - usage - wsdl2java jaxb
CXF codegen-plugin non funziona (1)
Devi inserire il plugin cxf-codegen nella tua parte build / plugins, non solo in build / pluginManagement / plugins.
Sto cercando di ottenere il plugin cxf-codegen per generare fonti dal mio file wsdl. Ma non succede nulla quando eseguo mvn generate-source con eclipse luna. Sembra che il plugin stesso non sia configurato correttamente.
Il mio pom.xml
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.webservice</groupId>
<artifactId>wsdlfirstwebservice</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>wsdlfirstwebservice Maven Webapp</name>
<url>http://maven.apache.org</url>
<properties>
<jdk.version>1.8</jdk.version>
<cxf.version>3.0.4</cxf.version>
<jaxb.version>2.2</jaxb.version>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.0.4</version>
</dependency>
</dependencies>
<build>
<finalName>Wrsdlfirstwebservice</finalName>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.1</version>
<configuration>
<webXml>src/main/webapp/WEB-INF/web.xml</webXml>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>src/main/resources/CustomerOrders.wsdl</wsdl>
<bindingFiles>
<bindingFile>src/main/resources/wsdl/binding.xml</bindingFile>
</bindingFiles>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>${jaxb.version}</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-xjc</artifactId>
<version>${jaxb.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
La mia wsdl
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions name="CustomerOrdersService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.wsdlfirstwebservice.com/customerorders"
targetNamespace="http://www.wsdlfirstwebservice.com/customerorders">
<!-- Types -->
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.wsdlfirstwebservice.com/customerorders"
targetNamespace="http://www.wsdlfirstwebservice.com/customerorders">
<xs:complexType name="order">
<xs:sequence>
<xs:element name="id" type="xs:integer"/>
<xs:element name="product" type="tns:product" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="product">
<xs:sequence>
<xs:element name="id" type="xs:integer" minOccurs="0"/>
<xs:element name="description" type="xs:string" minOccurs="0"/>
<xs:element name="quantity" type="xs:integer" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getOrdersRequest">
<xs:sequence>
<xs:element name="customerId" type="xs:integer" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="getOrdersResponse">
<xs:sequence>
<xs:element name="order" type="tns:order" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:element name="getOrdersRequest" type="tns:getOrdersRequest"/>
<xs:element name="getOrdersResponse" type="tns:getOrdersResponse"/>
</xs:schema>
</wsdl:types>
<!-- Messages :
These are analogous to method parameters and return types in java methods
-->
<wsdl:message name="getOrdersRequest">
<wsdl:part name="parameters" element="tns:getOrdersRequest">
</wsdl:part>
</wsdl:message>
<wsdl:message name="getOrdersResponse">
<wsdl:part name="parameters" element="tns:getOrdersResponse">
</wsdl:part>
</wsdl:message>
<!-- Port types
These are analogous to java methods. Port types use message as input and/or output.
-->
<wsdl:portType name="CustomerOrdersPortType">
<wsdl:operation name="getOrders">
<wsdl:input name="getOrdersRequest" message="tns:getOrdersRequest"></wsdl:input>
<wsdl:output name="getOrdersResponse" message="tns:getOrdersResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<!-- Bindings
This defines the message formats and protocol details for web service
-->
<wsdl:binding name="CustomerOrdersServiceSoapBinding" type="tns:CustomerOrdersPortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getOrders">
<soap:operation soapAction="" style="document"/>
<wsdl:input name="getOrdersRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getOrdersResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<!-- Service
Tells customer how to consume the service
-->
<wsdl:service name="CustomerOrdersService">
<wsdl:port name="CustomerOrdersPort" binding="tns:CustomerOrdersServiceSoapBinding">
<soap:address location="http://localhost:8080/wsdlfirstwebservice/services/CustomerOrdersService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
Uscita console
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T23: 07: 52 + 05: 30) Home Maven: D: \ JSPractice \ wsdlfirstwebservice \ EMBEDDED Versione Java: 1.8.0_60, fornitore: Oracle Corporation Java home: C: \ Programmi (x86) \ Java \ jdk1.8.0_60 \ jre Impostazioni locali predefinite: en_IN, codifica piattaforma: Cp1252 Nome sistema operativo: "windows 7", versione: "6.1", arch: "x86", famiglia: "dos" [INFO ] Gli stacktraces di errore sono attivati. [DEBUG] Lettura delle impostazioni globali da EMBEDDED \ conf \ settings.xml [DEBUG] Lettura delle impostazioni utente da C: \ Users \ D.Sama.m2 \ settings.xml [DEBUG] Utilizzo del repository locale in C: \ Users \ D.Sama .m2 \ repository [DEBUG] Utilizzo del gestore EnhancedLocalRepositoryManager con priorità 10.0 per C: \ Users \ D.Sama.m2 \ repository [INFO] Scansione per progetti ... [DEBUG] Regioni estensioni per progetto com.webservice: wsdlfirstwebservice: war: 0.0.1-SNAPSHOT: (nessuno) [DEBUG] Ricerca dei mapping lifecyle per la guerra di packaging da ClassRealm [plexus.core, parent: null] [DEBUG] === REACTOR BUILD PLAN =========== ===================================== [DEBUG] Progetto: com.webservice: wsdlfirstwebservice: war: 0.0.1-SNAPSHOT [DEBUG] Compiti:
[generate-sources] [DEBUG] Stile: Regular [DEBUG] ==================================== =================================== [INFO] [INFO] Utilizzo del builder org.apache.maven. lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder con un numero di thread pari a 1 [INFO]
[INFORMAZIONI] ----------------------------------------------- ------------------------- [INFO] Costruire wsdlfirstwebservice Maven Webapp 0.0.1-SNAPSHOT [INFO] ---------- -------------------------------------------------- ------------ [DEBUG] Default del ciclo di vita -> [convalida, inizializza, genera-sorgenti, origini processo, genera-risorse, risorse-processo, compila, classi processo, genera-test- fonti, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, preparazione-pacchetto, pacchetto, pre-integrazione-test, integrazione-test, post- integration-test, verificare, installare, distribuire] [DEBUG] Lifecycle clean -> [pre-clean, clean, post-clean] [DEBUG] Sito del ciclo di vita -> [pre-sito, sito, post-sito, site-deploy] [DEBUG] === PROJECT BUILD PLAN ========================================= ======= [DEBUG] Progetto: com.webservice: wsdlfirstwebservice: 0.0.1-SNAPSHOT [DEBUG] Dipendenze (collect): [] [DEBUG] Dipendenze (risoluzione): [] [DEBUG] Repository (dependenci es): [central ( http://repo.maven.apache.org/maven2 , releases)] [DEBUG] Repository (plugin): [centrale ( http://repo.maven.apache.org/maven2 , releases) ] [DEBUG] ============================================== ========================= [INFO] ---------------------- -------------------------------------------------- [INFO] BUILD SUCCESS [INFO] ------------------------------------------ ------------------------------ [INFO] Tempo totale: 0.101 s [INFO] Finito a:2016-09-11T14: 27: 19 + 05: 30 [INFO] Memoria finale: 4M / 15M [INFO]