Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/364.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java springboot赢得';不能从wsdl生成类_Java_Spring Boot_Soap_Wsdl - Fatal编程技术网

Java springboot赢得';不能从wsdl生成类

Java springboot赢得';不能从wsdl生成类,java,spring-boot,soap,wsdl,Java,Spring Boot,Soap,Wsdl,我尝试了一个关于通过spring boot()使用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"

我尝试了一个关于通过spring boot()使用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>

4.0.0
德鲍姆加滕
springwsdlconsume
0.1.0
org.springframework.boot
spring启动程序父级
2.0.3.1发布
1.8
org.springframework.boot
弹簧靴起动器
org.springframework.ws
SpringWS核心
org.springframework.boot
springbootmaven插件
org.jvnet.jaxb2.maven2
maven-jaxb2-plugin
0.12.3
生成
WSDL
de.baumgarten.springwsdlconsumer.hello.wsdl
http://localhost:8080/ws/my_wsdl.wsdl


Maven构建成功。似乎从未调用生成目标。但这只是猜测。

尝试删除标签
pluginManagement


它用于修复已确定版本的插件。

尝试使用以下插件:-

<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>

org.springframework.boot
springbootmaven插件
org.apache.cxf
cxf-codegen插件
3.2.4
生成源
生成源
${project.build.directory}/generated/cxf
${basedir}/src/main/resources/wsdl/wsdlFile.wsdl
wsdl2java
我还建议在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>

org.apache.cxf
cxf弹簧引导启动器jaxws
3.2.4
org.apache.cxf
cxf-codegen插件
3.2.4

在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>

org.springframework.boot
springbootmaven插件
org.jvnet.jaxb2.maven2
maven-jaxb2-plugin
0.14.0
数字转换
生成
WSDL
com.walking.techie.number.conversion.wsdl
${project.basedir}/src/main/java
http://www.dataaccess.com/webservicesserver/numberconversion.wso?WSDL
商务服务
生成
WSDL
com.walking.techie.wsdl
${project.basedir}/src/main/java
http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl
如果使用SpringBoot,则可以在pom.xml文件中包含以下maven依赖项。它将提供WebServiceGatewaySupport类。您可以在服务层扩展此类,并使用getWebServiceTemplate().MarshalSendReceive()方法调用wsdl服务。
org.springframework.ws
SpringWS核心

检查web服务URL
http://www.webservicex.com/stockquote.asmx?WSDL
。它不存在。我希望如果您指向一个返回WSDL的web服务url,它会起作用。感谢您的评论,但正如您所看到的,我的pom中有另一个url指向现有的WSDL;)我尝试使用web服务。而且它起作用了。奇怪的是,仍然没有班级