java 如何在给定 SOAP WSDL 操作的情况下创建 WSDL 文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2016836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 18:56:23  来源:igfitidea点击:

How to create WSDL file given SOAP WSDL operations

javasoapwsdlservice

提问by Epitaph

I haven't had any experience with web service related development. So, any ideas will be greatly appreciated.

我没有任何与 Web 服务相关的开发经验。因此,任何想法将不胜感激。

Suppose, I have a file listing draft specification of WSDL operations. Following is one example. How would I go about creating the WSDL file. Is notepad sufficient or do I need to have WSDL editor?

假设我有一个文件,列出了 WSDL 操作的规范草案。下面是一个例子。我将如何创建 WSDL 文件。记事本够用还是我需要 WSDL 编辑器?

getHostSystemInfo

Returns detailed information about host systems specified via given IDs.

返回有关通过给定 ID 指定的主机系统的详细信息。

  • input HostSystemIdCollection(Collection of Strings)
  • Output HostSystemInfoCollection
    • HostSystemInfo
      • Id: mandatory
      • Properties: Following properties should be provided for host systems
        • HostSystemName
        • HostSystemProperty1
        • HostSystemProperty2
        • HostSystemProperty3 .... ....
  • 输入 HostSystemIdCollection(字符串的集合)
  • 输出主机系统信息集合
    • 主机系统信息
      • 编号:必填
      • 属性:应为主机系统提供以下属性
        • 主机系统名称
        • 主机系统属性1
        • 主机系统属性2
        • HostSystemProperty3 .... ....

采纳答案by djna

If the question is just "how do I create the WSDL" then you could indeed use Notepad and just write it, it's only XML after all. However, writing syntactically correct XML by hand is pretty dull, and error prone. So I would recommend using WSDL aware tooling for example an Eclipse editor

如果问题只是“我如何创建 WSDL”,那么您确实可以使用记事本并直接编写它,毕竟它只是 XML。然而,手工编写语法正确的 XML 非常枯燥,而且容易出错。所以我建议使用 WSDL 感知工具,例如Eclipse 编辑器

An alternative is to write some Java which expresses the interface, and from it generate the WSDL. There are many ways of doing this, including starting with an EJB and annotating it accordingly. A few googles should help you find what you need.

另一种方法是编写一些表达接口的 Java,并从中生成 WSDL。有很多方法可以做到这一点,包括从 EJB 开始并相应地对其进行注释。一些谷歌应该可以帮助你找到你需要的东西。

My experience is that simple POC situations tend to work well starting at the Java. Larger scale projects benfit from considered designs starting at the WSDL.

我的经验是,从 Java 开始,简单的 POC 情况往往效果很好。更大规模的项目受益于从 WSDL 开始的经过深思熟虑的设计。

回答by manuel aldana

coding WSDL by hand is a big pain! i used a XML editor for creation of and then generated the stubs with JAXWS. It is important to understand and differences of the WSDL styles, which is not trivial (have a look at WSDL styles). a good help is to import the WSDL schema to your IDE (eclipse, idea) and then work with autocompletion.

手动编码 WSDL 是一个很大的痛苦!我使用 XML 编辑器创建并使用JAXWS生成存根。了解 WSDL 样式的差异很重要,这并非微不足道(查看WSDL 样式)。一个很好的帮助是将 WSDL 模式导入您的 IDE(eclipse、idea),然后使用自动完成功能。

just for interest, why are you using WSDL + SOAP. if you have a choice and you use anyway HTTP, have a look at REST. It can make implementation of web-api a LOT easier, both on server side and for api-clients.

只是出于兴趣,您为什么要使用 WSDL + SOAP。如果您有选择并且无论如何都使用 HTTP,请查看 REST。它可以使 web-api 的实现更容易,无论是在服务器端还是 api 客户端。

回答by Jamie McCrindle

If you haven't done any web services before, I would strongly recommend a WSDL Editor. The Netbeans has a plugin that should help.

如果您以前没有做过任何 Web 服务,我强烈建议您使用 WSDL 编辑器。Netbeans 有一个插件应该会有所帮助。

The other way of doing it, which may be easier is by using the Java annotations defined in JSR 181.

另一种可能更简单的方法是使用 JSR 181 中定义的 Java 注释。

回答by Pascal Thivent

Of course you could use the worst text editor in the world (!) but I'd seriouslyconsider using any decent XML editor or IDE (Eclipse's WSDL support is pretty decent). This will save you a lot of pain and suffer.

当然,您可以使用世界上最糟糕的文本编辑器(!),但我会认真考虑使用任何合适的 XML 编辑器或 IDE(Eclipse 的 WSDL 支持相当不错)。这将为您节省很多痛苦和痛苦。

Or, if this is an option, you could just annotate a Java class with JAX-WSannotations and have your WSDL dynamically generated from the Java code. Personally, I prefer the WSDL-first approach, the Java-first approach is just a suggestion to get you started.

或者,如果这是一个选项,您可以只使用JAX-WS注释对 Java 类进行注释,并从 Java 代码动态生成 W​​SDL。就个人而言,我更喜欢 WSDL-first 方法,Java-first 方法只是让您入门的一个建议。

回答by OscarRyz

You could use Axis2to create that for you.

您可以使用Axis2为您创建它。