繁体   English   中英

使用JDK工具wsimport从.NET 2.0应用程序生成的WSDL生成Java SOAP Web服务客户端时出现问题

[英]Problem generating Java SOAP web services client with JDK tool wsimport from a WSDL generated by a .NET 2.0 application

我正在尝试使用JDK 6工具wsimport为一些SOAP Web服务生成客户端。 WSDL由.NET 2.0应用程序生成。 对于.NET 3.X应用程序,它工作正常。

我跑的时候

wsimport -keep -p mypackage http://myservice?wsdl

它显示了几个错误消息,如下所示:

[错误]具有相同名称“mypackage.SomeClass”的类/接口已在使用中。 使用类自定义来解决此冲突。 线? http:// myservice?wsdl

当我使用Axis 1.4(使用Eclipse WebTools插件)生成Web服务客户端时。

有谁知道我可以做什么才能使用wsimport工具? 我真的不明白“类定制”是什么。

我不知道这是否曾经解决,但我花了一些时间谷歌搜索解决同样的问题。

我在这里找到了解决方法 - https://jax-ws.dev.java.net/issues/show_bug.cgi?id=228

解决方案是使用-B-XautoNameResolution运行wsimport(无空格)

对于使用maven阅读此内容的任何人,这是如何将其添加到.pom文件中。 请注意配置部分中的args。 这在文档中不是很容易找到。 非常感谢Isaac Stephens对此的帮助。

<!-- 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:complexType同名 - 如下例所示。 所有类型和操作都应具有唯一的名称。

<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文件指定不同的目标包。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM