【问题标题】:How to import WSDL file for developing SOAP webservice using MAVEN?如何导入 WSDL 文件以使用 MAVEN 开发 SOAP Web 服务?
【发布时间】:2017-03-19 01:54:22
【问题描述】:
我是 SOAP 网络服务的新手。我有一个 WSDL 文件和一个 XSD 文件。我必须使用 maven 创建 webservice 及其相应的 webservice 客户端。
我已经在eclipse中导入了WSDL文件,它会自动生成所有的类并运行webservice。但我想使用 maven 项目做同样的事情。
请建议我如何实现这一目标的步骤?
【问题讨论】:
标签:
web-services
maven
jakarta-ee
soap
wsdl
【解决方案1】:
您可以使用 cxf-apache-maven。
只需在您的 pom.xml 文件中设置依赖项即可。示例:
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>3.1.6</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>3.1.6</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.1.6</version>
<executions>
<execution>
<id>ID NAME</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>WSDL FILE LOCATION/URL</wsdl>
<extraargs>
<extraarg>-p</extraarg>
<extraarg> DESTINATION PACKAGE </extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
您可以在 apache 文档中查看其他示例:http://cxf.apache.org/docs/maven-cxf-codegen-plugin-wsdl-to-java.html
另一个选项是使用 jaxws-maven-plugin,类似。
搜索两者以找到更适合您的情况。