我有使用wsimport生成源的soap客户端 我在我的pom.xml中使用以下设置
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.10</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlFiles>
<wsdlFile>example.com_8080/services/test.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>http://example.com:8080/services/test?wsdl</wsdlLocation>
<staleFile>${project.build.directory}/jaxws/stale/test.stale</staleFile>
</configuration>
<id>wsimport-generate-test</id>
<phase>generate-sources</phase>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>javax.xml</groupId>
<artifactId>webservices-api</artifactId>
<version>1.4</version>
</dependency>
</dependencies>
<configuration>
<sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>
<xnocompile>true</xnocompile>
<verbose>true</verbose>
<extension>true</extension>
<catalog>${basedir}/src/jax-ws-catalog.xml</catalog>
</configuration>
</plugin>
我正在寻找最好的方法,每次都不要从远程服务器( http://example.com:8080/services/test?wsdl )对wsdl / xsd做请求。 所以,我想使用本地wsdl / xsd文件。有可能吗?genra
答案 0 :(得分:0)
有类似的问题。 wsimport应该生成一个名为your_ws_nameService.java的.java文件。在此文件中,您应该具有如下所示的部分:
static {
URL url = null;
try {
URL baseUrl;
baseUrl = com.oracle.xmlns.orawsv.ORAWSVService.class.getResource(".");
url = new URL(baseUrl, "http://127.0.0.1:7101/test/test?WSDL");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'http://127.0.0.1:7101/test/test?WSDL', retrying as a local file");
logger.warning(e.getMessage());
}
ORAWSVSERVICE_WSDL_LOCATION = url;
}
将此部分更改为以下内容:
static {
URL url = null;
try {
URL baseUrl;
baseUrl = mypackage.my_ws_client.my_ws_clientService.class.getResource("my_ws.wsdl");
url = new URL(baseUrl,"");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the local wsdl file.");
logger.warning(e.getMessage());
}
SENDINFOSERVICE_WSDL_LOCATION = url;
}
这将读取位于客户端内部的WSDL文件。当然你需要先在那里使用它,就像kolossus建议的那样,你可以从浏览器下载。