使用 JDK 工具 wsimport 从 .NET 2.0 应用程序生成的 WSDL 生成 Java SOAP Web 服务客户端时出现问题
我正在尝试使用 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我不知道这个问题是否已经解决,但我花了一些时间在谷歌上搜索同一问题的解决方案。
我在这里找到了修复 - https://jax-ws.dev .java.net/issues/show_bug.cgi?id=228
解决方案是使用
-B-XautoNameResolution
(无空格)运行 wsimportI 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)对于任何使用 maven 阅读本文的人来说,这是将其添加到 .pom 文件的方法。 请注意配置部分中的参数。 这在文档中不太容易找到。 非常感谢艾萨克·斯蒂芬斯为此提供的帮助。
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.
上面接受的答案可以解决您的问题,但不能解决根本原因。
发生此问题的原因是 wsdl 文件中的操作与 xsd 文件中的 xsd:complexType 具有相同的名称 - 如下例所示。 所有类型和操作都应该有唯一的名称。
因此,请检查您的操作和类型。 确保它们都没有相同的名称,即没有重复的名称。
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.
So check your operations and types. Make sure none of them have the same name i.e. no duplicate names.
您可能会从同一个包中的 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.