简体   繁体   中英

java eclipse how to generate java classes from wsdl

I work with Eclipse and I have a wsdl. Now, I need to generate the java classes from this wsdl.

How can I do this from Eclipse?

All you need to familiar with maven , add following dependencies and some configuration for your WSDL files.

1) First add these Dependencies

<dependencies>
    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.2.11</version>
    </dependency>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <version>2.3.0</version>
        <type>pom</type>
    </dependency>
</dependencies>

2) Add Configuration for WSDL file

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>2.5</version>
            <executions>
                <execution>
                    <id>wsimport-from-jdk</id>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <wsdlUrls>
                    <wsdlUrl>
                        https://example.com/mywsdl.wsdl
                    </wsdlUrl>
                </wsdlUrls>
                <packageName>com.sample.wsdl.client</packageName>
                <sourceDestDir>src\main\java</sourceDestDir>
            </configuration>
        </plugin>
    </plugins>
</build>

3) Build source code

mvn generate-sources run this command in your root folder of this project where pom.xml resides.

For more details github sample

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM