阅读背景:

使用Maven的jaxws-maven-plugin插件,将wsdl生成java

来源:互联网 

1、准备一个标准的maven工程,将pom.xml修改成如下:

<pre name="code" class="xml">
<?xml version="1.0" encoding="ISO-8859-1"?>
<project xmlns="https://maven.apache.org/POM/4.0.0" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="   https://maven.apache.org/POM/4.0.0 https://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.test</groupId>
	<artifactId>TEST_WS</artifactId>
	<packaging>jar</packaging>
	<name>TEST WS</name>
	<version>1.0.0</version>
	<description>
		Web service
	</description>
	<properties>
		<!-- 这个目录用于存放生成后的JAVA,如果不存在就先创建好了 -->
		<genSource.dir>src/gen/java</genSource.dir>
		<!-- 指定bingding文件所在的目录,在这个示例中只指定了bindingDirectory,而没有指定bindingFile,那说明只要是这个目录下面的所有xml文件都会被使用 -->
		<!-- 使用帮助,参看:https://www.oracle.com/technetwork/articles/entarch/jax-ws-jaxb-customization-082750.html, https://jax-ws-commons.java.net/jaxws-maven-plugin/wsimport-mojo.html#bindingDirectory -->
		<jaxwsBing.dir>src/jaxws/testService</jaxwsBing.dir>
		<!-- WSDL及xsd文件所在的路径,只需要指明wsdl文件即可,因为wsdl文件中会引用到xsd -->
		<wsdlFile>testService/TestService.wsdl</wsdlFile>
	</properties>
	<build>
		<plugins>
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>jaxws-maven-plugin</artifactId>
				<version>1.12</version>
				<dependencies>
					<dependency>
						<artifactId>jsr181</artifactId>
						<groupId>javax.jws</groupId>
						<version>1.0</version>
					</dependency>
				</dependencies>
				<configuration>
					<destDir /> <!-- don't need .class files -->
					<extension>true</extension>
					<keep>true</keep>
					<sourceDestDir>${project.basedir}/${genSource.dir}</sourceDestDir>
					<target>2.1</target>
					<verbose>true</verbose>
				</configuration>
				<executions>
					<execution>
						<id>wsimport-IsatService</id>
						<phase>process-sources</phase>
						<goals>
							<goal>wsimport</goal>
						</goals>
						<configuration>
							<bindingDirectory>${project.basedir}/${jaxwsBing.dir}</bindingDirectory>
							<wsdlFiles>
								<wsdlFile>${wsdlFile}</wsdlFile>
							</wsdlFiles>
						</configuration>
					</execution>
				</executions>
			</plugin>

		</plugins>
	</build>
	<dependencies>
		<dependency>
			<artifactId>jaxws-api</artifactId>
			<groupId>javax.xml.ws</groupId>
			<scope>provided</scope>
			<version>2.1-1</version>
		</dependency>
	</dependencies>
</project><pre name=



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: