Ale*_*lex 19 java wsdl web-services jax-ws maven
我有一个JAX-WS驱动的Web服务,其WSDL我们从另一个Maven模块生成一个Web服务客户端(我将调用它ws-consumer).
无论好坏,我们将"已发布的WSDL"(服务在发布时保存/生成的WSDL和XSD的版本)src/wsdl复制到我们的文件夹中ws-consumer,然后使用jaxws-maven-pluginorg.jvnet生成使用jaxws:wsimport以下内容的客户端(截断)配置:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<!--phase>generate-sources</phase -->
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<wsdlDirectory>src/main/resources/META-INF/wsdl/</wsdlDirectory>
<wsdlFiles>
<wsdlFile>MyWS/MyWS.wsdl</wsdlFile>
</wsdlFiles>
</configuration>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
现在,生成的客户端代码在类级别应用了以下注释:
@WebServiceClient(name = "MyWS", targetNamespace = "http://myws/blah", wsdlLocation = "**file:/C:/some/absolute/path/src/main/resources/META-INF/wsdl/MyWS/MyWS.wsdl"**)
Run Code Online (Sandbox Code Playgroud)
强调我的
正如您所希望看到的那样,wsdlLocation属性值具有硬编码的绝对路径,在部署服务时该路径将不正确.
有什么方法可以通过将其设置为just META-INF/wsdl/MyWS/MyWS.wsdl或其他值来"控制"它?
McD*_*ell 13
可以使用Codehaus插件:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>1.9</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<keep>true</keep>
<verbose>true</verbose>
<wsdlDirectory>../wscontract/src/main/resources/wsdl</wsdlDirectory>
<wsdlLocation>wsdl/MaintainAddress.wsdl</wsdlLocation>
<sourceDestDir>src/main/java</sourceDestDir>
<bindingDirectory>.</bindingDirectory>
<bindingFiles>
<bindingFile>jaxb/xsdbindings.xml</bindingFile>
<bindingFile>jaxb/wsdlbindings.xml</bindingFile>
</bindingFiles>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
也许您使用的插件有类似的选项,或者您可以考虑切换.
您还可以显式配置WSDL,在这种情况下,将忽略此属性,但这可能不适合容器管理的应用程序.
这里有示例代码.
将wsdlLocation与org.jvnet.jax-ws-commons中的jaxws-maven-plugin一起使用:
<plugin>
<groupId>org.jvnet.jax-ws-commons</groupId>
<artifactId>jaxws-maven-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<goals>
<goal>wsimport</goal>
</goals>
</execution>
</executions>
<configuration>
<wsdlDirectory>src/main/resources/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>arsdev.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>wsdl/*</wsdlLocation>
<!-- Keep generated files -->
<keep>true</keep>
<packageName>jaxws.remedy.client.generated</packageName>
<!-- generated source files destination -->
<sourceDestDir>target/generated-code/src</sourceDestDir>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29925 次 |
| 最近记录: |