问题从由.NET 2.0应用程序所产生的WSDL生成Java SOAP网络服务客户端,与JDK工具的wsimport
-
16-09-2019 - |
题
我试图生成使用JDK 6工具wsimport
一些SOAP Web服务客户端。
用.NET 2.0应用程序所产生的WSDL。对于.NET 3.X应用程序,它工作得很好。
当我运行
wsimport -keep -p mypackage http://myservice?wsdl
它示出了这样的几个错误消息:
[ERROR]具有相同的名称“mypackage.SomeClass” A类/接口已在使用中。 使用一类定制解决这个矛盾。行?的 HTTP://为MyService WSDL
当我生成使用Axis 1.4 Web服务客户端(使用Eclipse WebTools的插件)。
有谁知道我能以使用wsimport
工具吗?我真的不明白“类定制”的东西是什么。
解决方案
我不知道这是否是以往任何时候都解决了,但我花了一些时间google搜索解决这个同样的问题。
我找到了解决此处 - 的https:// JAX- ws.dev.java.net/issues/show_bug.cgi?id=228
在解决方案是运行与-B-XautoNameResolution
的wsimport(没有空格)
其他提示
有关任何人阅读本使用行家,这是如何将它添加到.pom文件。请注意,在配置部分的ARGS。这不是很容易找到的文档。非常感谢艾萨克·斯蒂芬斯对他这方面的帮助。
<!-- definition for ERPStandardWork service -->
<execution>
<id>ERPStandardWorkService</id>
<goals>
<goal>wsimport</goal>
</goals>
<configuration>
<!-- this resolves naming conflicts within the wsdl - there are several copies of fault report objects which clash otherwise. -->
<args>
<arg>-B-XautoNameResolution</arg>
</args>
<wsdlDirectory>${basedir}/src/main/resources/META-INF/wsdl</wsdlDirectory>
<wsdlFiles>
<wsdlFile>ERPStandardWork.wsdl</wsdlFile>
</wsdlFiles>
<wsdlLocation>${basedir}/src/main/resources/META-INF/wsdl/ERPStandardWork.wsdl
</wsdlLocation>
<staleFile>${project.build.directory}/jaxws/ERPStandardWork/.staleFlag
</staleFile>
</configuration>
</execution>
接受的答案以上会帮助解决问题,但难道不固定的根本原因。
这个问题正在发生,因为您的WSDL文件的操作具有相同的名称作为一个xsd:在你的XSD文件中复杂类型 - 如下面的例子。所有类型和操作应该有唯一的名称。
<xsd:complexType name="SearchDocuments">
<xsd:sequence>
<xsd:element name="document" type="ns0:SearchDocumentById" maxOccurs="unbounded"/>
</xsd:sequence>
</xsd:complexType>
<operation name="SearchDocuments">
<input wsam:Action="http://controller.xxx.xxx.com/DocumentWS/searchDocumentsRequest" message="tns:searchDocumentsRequest"/>
<output wsam:Action="http://controller.xxx.xxx.com/DocumentWS/searchDocumentsResponse" message="tns:searchDocumentsResponse"/>
</operation>
因此,检查您的操作和类型。确保没有人具有相同的名称,即没有重复的名字。
您可能来自在同一封装中的WSDL文件生成的所有类。如果是这样的话,可以尝试使用不同的目标封装用的wsimport的-p选项每个WSDL文件。