【问题标题】:java11 soap wsdl2java :how to create a class from wsdl file in javajava11 soap wsdl2java:如何在java中从wsdl文件创建一个类
【发布时间】:2021-03-04 16:10:48
【问题描述】:

我正在使用 java11 在soap 中创建 web 服务,并且已经创建了 wsdl 文件,然后我尝试从 wsdl 文件生成 java 类,但发生了错误。在 java11 中,wsimport 和 wsgen 已被删除,因此我在 pom.xml 文件中添加了适当的依赖项。如果对此有任何错误或替代解决方案,请提及我将在下面分享屏幕截图和 pom.xml。

i dont know what error is this javax/jws/soap/SOAPBinding$Style kindly check this

这是我用过的pom.xml文件

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<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>
      
    <packaging>war</packaging>
      
    <version>0.1.0-SNAPSHOT</version>
      
    <groupId>com.inno.innowebservices</groupId>
      
    <artifactId>InnoWebservices1</artifactId>
      
    <properties>
            
        <appengine.maven.plugin.version>2.4.0</appengine.maven.plugin.version>
            
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
            
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
            
        <maven.compiler.source>1.8</maven.compiler.source>
            
        <maven.compiler.target>1.8</maven.compiler.target>
            
        <maven.compiler.showDeprecation>true</maven.compiler.showDeprecation>
          
    </properties>
      
    <dependencyManagement>
            
        <dependencies>
                  
            <dependency>
                        
                <groupId>com.google.cloud</groupId>
                        
                <artifactId>libraries-bom</artifactId>
                        
                <version>15.0.0</version>
                        
                <type>pom</type>
                        
                <scope>import</scope>
                      
            </dependency>
                
        </dependencies>
          
    </dependencyManagement>
      
    <dependencies>
            
        <!-- Compile/runtime dependencies -->
            
        <dependency>
                  
            <groupId>javax.servlet</groupId>
                  
            <artifactId>javax.servlet-api</artifactId>
                  
            <version>3.1.0</version>
                  
            <scope>provided</scope>
                
        </dependency>
        
        <dependency>
            <groupId>org.glassfish.metro</groupId>
            <artifactId>webservices-rt</artifactId>
            <version>2.3</version>
        </dependency>

       <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.3.2</version>
         </dependency>
            
        <dependency>
                  
            <groupId>javax.servlet.jsp</groupId>
                  
            <artifactId>javax.servlet.jsp-api</artifactId>
                  
            <version>2.3.1</version>
                  
            <scope>provided</scope>
                
        </dependency>
            
        <dependency>
                  
            <groupId>jstl</groupId>
                  
            <artifactId>jstl</artifactId>
                  
            <version>1.2</version>
                
        </dependency>
            
        <dependency>
            <groupId>com.google.appengine</groupId>
            <artifactId>appengine-api-1.0-sdk</artifactId>
            <version>1.9.83</version>
        </dependency>
        <dependency>
            <groupId>com.google.endpoints</groupId>
            <artifactId>endpoints-framework</artifactId>
            <version>2.2.1</version>
        </dependency>
        <dependency>
            <groupId>com.googlecode.objectify</groupId>
            <artifactId>objectify</artifactId>
            <version>6.0.7</version>
        </dependency>
        <!-- Test Dependencies -->
            
        <dependency>
                  
            <groupId>junit</groupId>
                  
            <artifactId>junit</artifactId>
                  
            <version>4.12</version>
                  
            <scope>test</scope>
                
        </dependency>
          
    </dependencies>
      
    <build>
            
        <!-- for hot reload of the web application-->
            
        <outputDirectory>${project.build.directory}/${project.build.finalName}/WEB-INF/classes</outputDirectory>
            
        <plugins>
                  
            <plugin>
                        
                <groupId>com.google.cloud.tools</groupId>
                        
                <artifactId>appengine-maven-plugin</artifactId>
                        
                <version>${appengine.maven.plugin.version}</version>
                      
            </plugin>
                  
      
            <plugin>
                        
                <groupId>org.apache.maven.plugins</groupId>
                        
                <artifactId>maven-enforcer-plugin</artifactId>
                        
                <version>3.0.0-M3</version>
                        
                <executions>
                              
                    <execution>
                                    
                        <id>enforce-maven</id>
                                    
                        <goals>
                                          
                            <goal>enforce</goal>
                                        
                        </goals>
                                    
                        <configuration>
                                          
                            <rules>
                                                
                                <!-- appengine-maven-plugin requires Maven 3.5.0 or later -->
                                                
                                <requireMavenVersion>
                                                      
                                    <version>3.5.0</version>
                                                    
                                </requireMavenVersion>
                                              
                            </rules>
                                        
                        </configuration>
                                  
                    </execution>
                            
                </executions>
                      
            </plugin>
                
        </plugins>
          
    </build>
    
</project>

【问题讨论】:

    标签: maven soap pom.xml java-11 wsdl2java


    【解决方案1】:

    jaxws-maven-plugin 较新版本可用于使用 Java 11 从 wsdl 生成类。以下插件配置可能会有所帮助 - 经过测试并且工作正常:

    <plugin>
                    <groupId>com.sun.xml.ws</groupId>
                    <artifactId>jaxws-maven-plugin</artifactId>
                    <version>2.3.2</version>
                    <executions>
                        <execution>
                            <id>generate-java-sources</id>
                            <phase>process-sources</phase>
                            <goals>
                                <goal>wsimport</goal>
                            </goals>
                            <configuration>
                                <extension>true</extension>
                                <wsdlFiles>
                                    <wsdlFile>${basedir}/src/wsdl/yourservice.wsdl</wsdlFile>
                                </wsdlFiles>
                                <wsdlLocation>/src/wsdl/yourservice.wsdl</wsdlLocation>
                            </configuration>
                        </execution>
                    </executions>
                    <dependencies>
                        <dependency>
                            <groupId>javax.annotation</groupId>
                            <artifactId>javax.annotation-api</artifactId>
                            <version>1.3.2</version>
                        </dependency>
                        <dependency>
                            <groupId>javax.xml.bind</groupId>
                            <artifactId>jaxb-api</artifactId>
                            <version>2.3.1</version>
                        </dependency>
                        <dependency>
                            <groupId>javax.xml.ws</groupId>
                            <artifactId>jaxws-api</artifactId>
                            <version>2.3.1</version>
                        </dependency>
                        <dependency>
                            <groupId>javax.jws</groupId>
                            <artifactId>javax.jws-api</artifactId>
                            <version>1.1</version>
                        </dependency>                   
                        <dependency>
                            <groupId>com.sun.xml.bind</groupId>
                            <artifactId>jaxb-impl</artifactId>
                            <version>2.3.1</version>
                        </dependency>
                    </dependencies>
                </plugin>
    

    【讨论】:

      【解决方案2】:

      使用 Java 11。长期以来一直在寻找使用 wsdl2java 从 WSDL 创建 Java 类的解决方案。最后设法做到了这一点。没有选项可以将 zip 文件附加到消息中,所以我会描述。

      我创建了 2 个 bat 文件。下一个内容

      1. wsdl2java.bat

      "JDK_PATH\bin\java.exe" -cp -cp axis-1.4.jar;commons-logging-1.2.jar;commons-discovery-0.5.jar;javax.xml.rpc-api-1.1.2.jar;javax.xml.soap-api-1.4.0.jar;axis-wsdl4j-1.5.1.jar;activation-1.1.1.jar;javax.mail-api-1.6.2.jar org.apache.axis.wsdl.WSDL2Java %*

      1. runMe.bat

      wsdl2java -p package.name.to.save Filename.wsdl

      你需要从https://mvnrepository.com下载所有这些jar文件

      【讨论】:

        猜你喜欢
        • 2017-07-25
        • 1970-01-01
        • 1970-01-01
        • 2013-01-31
        • 2013-03-07
        • 2018-09-23
        • 1970-01-01
        • 1970-01-01
        • 2014-05-22
        相关资源
        最近更新 更多