How to generate classes from wsdl using Maven and wsimport?

后端 未结 7 891
时光说笑
时光说笑 2020-12-01 00:35

When I attempt to run \"mvn generate-sources\" this is my output :

SLF4J: Failed to load class \"org.slf4j.impl.StaticLoggerBinder\".
SLF4J: Defaulting to n         


        
相关标签:
7条回答
  • 2020-12-01 01:01

    Here is an example of how to generate classes from wsdl with jaxws maven plugin from a url or from a file location (from wsdl file location is commented).

    <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">
    <build>  
        <plugins>           
            <!-- usage of jax-ws maven plugin-->
            <plugin> 
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>1.12</version>
                <executions> 
                    <execution> 
                        <id>wsimport-from-jdk</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!-- using wsdl from an url -->
                    <wsdlUrls>
                        <wsdlUrl>
                            http://myWSDLurl?wsdl
                        </wsdlUrl>
                    </wsdlUrls>
                    <!-- or using wsdls file directory -->
                        <!-- <wsdlDirectory>src/wsdl</wsdlDirectory> -->
                    <!-- which wsdl file -->
                    <!-- <wsdlFiles> -->
                        <!-- <wsdlFile>myWSDL.wsdl</wsdlFile> -->
                    <!--</wsdlFiles> -->
                    <!-- Keep generated files -->
                    <keep>true</keep> 
                    <!-- Package name --> 
                    <packageName>com.organization.name</packageName> 
                    <!-- generated source files destination-->
                    <sourceDestDir>target/generatedclasses</sourceDestDir>
                </configuration>
            </plugin>
        </plugins>  
    </build>  
    

    0 讨论(0)
提交回复
热议问题