我尝试了一个有关通过Spring Boot(GETTING STARTED - Consuming a SOAP web service)使用SOAP Web服务的教程。但是,在运行Maven构建时不会生成类。我是这个主题的新手,需要一些帮助来发现我的错误。这是我的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>de.baumgarten</groupId>
<artifactId>springwsdlconsume</artifactId>
<version>0.1.0</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
</parent>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<!-- tag::wsdl[] -->
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.12.3</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>de.baumgarten.springwsdlconsume.hello.wsdl</generatePackage>
<schemas>
<schema>
<url>http://localhost:8080/ws/my_wsdl.wsdl</url>
</schema>
</schemas>
</configuration>
</plugin>
<!-- end::wsdl[] -->
</plugins>
</pluginManagement>
</build>
Maven构建成功。似乎从未调用过生成目标。但这只是一个猜测。
答案 0 :(得分:3)
尝试使用以下插件:-
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.2.4</version>
<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/wsdl/wsdlFile.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
我还建议您在pom.xml中具有以下依赖项:-
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-spring-boot-starter-jaxws</artifactId>
<version>3.2.4</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.2.4</version>
</dependency>
答案 1 :(得分:1)
尝试删除标签pluginManagement
它用于修复确定的插件版本。
答案 2 :(得分:0)
在pom.xml中尝试以下代码。当您使用多个wdsl时,这将帮助您生成Java类。如果您使用的是单个WSDL,则从下面的代码中删除最后一个执行块。
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jvnet.jaxb2.maven2</groupId>
<artifactId>maven-jaxb2-plugin</artifactId>
<version>0.14.0</version>
<executions>
<execution>
<id>number-conversion</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.walking.techie.number.conversion.wsdl</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<schemas>
<schema>
<url>http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL</url>
</schema>
</schemas>
</configuration>
</execution>
<execution>
<id>commerce-service</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<schemaLanguage>WSDL</schemaLanguage>
<generatePackage>com.walking.techie.wsdl</generatePackage>
<generateDirectory>${project.basedir}/src/main/java</generateDirectory>
<schemas>
<schema>
<url>http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl</url>
</schema>
</schemas>
</configuration>
</execution>
</executions>
</plugin>
You can include the below maven dependency in the pom.xml file if you are using spring boot. It will provide WebServiceGatewaySupport class. You can extend this class in service layer and use getWebServiceTemplate().marshalSendAndReceive() method to call the wsdl service.
<dependency>
<groupId>org.springframework.ws</groupId>
<artifactId>spring-ws-core</artifactId>
</dependency>