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

发布于 2024-07-17 05:41:16 字数 533 浏览 11 评论 0原文

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

当我运行时,

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

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

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

(使用 Eclipse WebTools 插件) 。

有人知道我可以做什么才能使用 wsimport 工具吗? 我实在不明白“类定制”是什么东西。

I'm trying to generate a client for some SOAP web services using the JDK 6 tool wsimport.
The WSDL was generated by a .NET 2.0 application. For .NET 3.X applications, it works fine.

When I run

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

it shows several error messages like this:

[ERROR] A class/interface with the same name "mypackage.SomeClass" is already in use.
Use a class customization to resolve this conflict. line ?? of http://myservice?wsdl

When I generate the web services client using Axis 1.4 (using the Eclipse WebTools plug-in).

Does anybody know what can I do in order to use the wsimport tool? I really don't understand what the "class customization" thing is.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

雨夜星沙 2024-07-24 05:41:16

我不知道这个问题是否已经解决,但我花了一些时间在谷歌上搜索同一问题的解决方案。

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

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

I don't know if this was ever solved, but I spent some time googling for a solution to this same problem.

I found a fix here - https://jax-ws.dev.java.net/issues/show_bug.cgi?id=228

The solution is to run wsimport with the -B-XautoNameResolution (no spaces)

路还长,别太狂 2024-07-24 05:41:16

对于任何使用 maven 阅读本文的人来说,这是将其添加到 .pom 文件的方法。 请注意配置部分中的参数。 这在文档中不太容易找到。 非常感谢艾萨克·斯蒂芬斯为此提供的帮助。

<!-- 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>

For anyone reading this using maven, this is how to add it to the .pom file. Note the args in the configuration section. This is not very easily found in documentation. Many thanks to Isaac Stephens for his help with this.

<!-- 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>
红玫瑰 2024-07-24 05:41:16

上面接受的答案可以解决您的问题,但不能解决根本原因。

发生此问题的原因是 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>

因此,请检查您的操作和类型。 确保它们都没有相同的名称,即没有重复的名称。

The accepted answer above would solve your problem but wouldnt fix the underlying cause.

The issue is happening because an operation in your wsdl file has the same name as an xsd:complexType in your xsd file - like the example below. All types and operations should have unique names.

<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>

So check your operations and types. Make sure none of them have the same name i.e. no duplicate names.

明明#如月 2024-07-24 05:41:16

您可能会从同一个包中的 WSDL 文件生成所有类。 如果是这种情况,请尝试使用 wsimport 的 -p 选项为每个 WSDL 文件指定不同的目标包。

You are possibly generating all the classes from the WSDL file in the same package. If that is the case, try specifying a different target package for each WSDL file with the -p option of wsimport.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文