我想使用Apache CXG Maven插件(WSLD2Java)生成java类来生成Web服务客户端。
我有一个可行的配置,但当我离线或服务器不可用时,生成源失败。
错误是无法创建wsdl定义:来自“wsdl 位置“...操作超时。
从我收集的内容来看,该工具无法访问该服务,因此无法获取XSD,反过来也会失败。
我有WSDL和XSD,我如何让Maven插件配置为使用文件的本地副本而不是从服务器请求额外的数据?
修改 我通过直接编辑WSDL使其“正常工作”。我将XSD Import标签修改为>请参阅与WSDL位于同一文件夹中的XSD。
编辑WSDL解决方案似乎很讨厌,我更喜欢我可以配置的东西。有什么想法吗?
POM文件设置如下,减去artefact id:
<?xml version="1.0" encoding="UTF-8"?>
<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">
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<version>2.7.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.16</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.16</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable>
<arguments>
<argument>-classpath</argument>
<classpath />
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>CXF</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>2.7.10</version>
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>2.7.10</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>2.7.10</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals><goal>wsdl2java</goal></goals>
<configuration>
<sourceRoot>${basedir}/target/generated-sources</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdls/WebService.wsdl</wsdl>
<wsdlLocation>classpath:WebService.wsdl</wsdlLocation>
</wsdlOption>
</wsdlOptions>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>