“java表单生成器”从给定的 wsdl 文件

发布于 2024-08-16 05:27:27 字数 694 浏览 5 评论 0原文

我正在尝试用 java 开发一个表单生成器,用户可以在其中编写 wsdl url 并获取 ComboBox 中 Web 服务支持的操作列表。当用户选择 ComboBox 中的一项时,他将看到使用 wsdl url 生成的表单字段。

我是 Web 服务技术的新手,在网上搜索 Web 服务解析器后,我决定使用 axis 库。但我真的不知道应该解析 wsdl 文档的哪一部分,

我并没有尝试创建 Web 服务的 java 类,我必须为任何 wsdl url 生成表单字段。

例如,这里有一个提供 9 种操作的 Web 服务

http://services.aonaware.com/DictService /DictService.asmx

和 wsdl 文件位于:

http://services .aonaware.com/DictService/DictService.asmx?WSDL

我需要知道应该解析 wsdl 文件的哪些部分,任何帮助将不胜感激。

I'm trying to develop a form generator in java, in which users will be able to write a wsdl url and get the list of the operations supported by the web service in a ComboBox. When the user selects one of the items in ComboBox then he will see form fields generated using the wsdl url.

I'm a newbie in web service technologies, after searching about web service parsers on the net I decided to use axis library. But I really do not know which part of the wsdl document should I parse

I'm not trying to create java classes of the web service, I have to generate form fields for any wsdl url.

For instance here is a web service which provides 9 operations

http://services.aonaware.com/DictService/DictService.asmx

and the wsdl file is here:

http://services.aonaware.com/DictService/DictService.asmx?WSDL

I need to know which parts of wsdl file should be parsed, any help would be appreciated.

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

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

发布评论

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

评论(4

背叛残局 2024-08-23 05:27:27

要开始使用 WSDL 并了解此类文档的结构,您可能应该查看一些文章,例如 了解 WSDLWSDL 教程 或任何您可以在 Google 上找到的其他初学者资源。

现在,要以简化的方式回答您的问题,您必须从包含以下内容的 portType 元素开始:

由一个或多个端点(通常称为接口)支持的一组抽象操作;操作是通过消息交换来定义的

例如,在您的情况下:

<wsdl:operation name="DictionaryList">
  <wsdl:documentation>Returns a list of available dictionaries</wsdl:documentation>
  <wsdl:input message="tns:DictionaryListSoapIn"/>
  <wsdl:output message="tns:DictionaryListSoapOut"/>
</wsdl:operation>

并且,对于每个操作,您需要解析输入和输出消息,消息是:

抽象消息的定义,可能由多个部分组成,每个部分可能属于不同的类型。

这里,例如上一个操作的输入消息是:

<wsdl:message name="DictionaryListSoapIn">
  <wsdl:part name="parameters" element="tns:DictionaryList"/>
</wsdl:message>

然后,为了了解消息的内容,看一下types

使用 XML 模式定义的抽象类型定义的容器

这里,DictionaryList 元素被定义为一个空的 compleType:

<s:element name="DictionaryList">
  <s:complexType/>
</s:element>

正如我所说,这实际上是一个非常简化的答案,因为 WSDL 无法用四段来概括而且,说实话,你要做的事情确实不是一件小事。让我重新表述一下:会有血!所以,即使这几行可以帮助你(很少)开始,我绝对不会从头开始这样一个项目,而是使用现有的库或工具(例如 Xydra 或 Eclipse XML 表单生成器 或 ...),这将允许不重新发明轮子。

顺便说一句,我注意到您已决定使用 Axis,并且不想生成 Java 类,但我强烈建议您不要使用 Axis。实际上,我会使用 JAX-WS RI,它捆绑在 Java 6 中,并且是一个更简单的 API。为了以防万一,要生成 Java 类,只需执行:

$ mkdir generated
$ wsimport -d generated http://services.aonaware.com/DictService/DictService.asmx?WSDL

To get started with WSDL and understand how such a document is structured, you should maybe have a look at some article like Understanding WSDL or the WSDL Tutorial or any other beginner resource that you'll find on Google.

Now, to answer your question in a simplified way, you'll have to start with the portType element that contains:

An abstract set of operations supported by one or more endpoints (commonly known as an interface); operations are defined by an exchange of messages

For example, in your case:

<wsdl:operation name="DictionaryList">
  <wsdl:documentation>Returns a list of available dictionaries</wsdl:documentation>
  <wsdl:input message="tns:DictionaryListSoapIn"/>
  <wsdl:output message="tns:DictionaryListSoapOut"/>
</wsdl:operation>

And, for each operation, you'll need to parse the input and output messages, a message being:

A definition of an abstract message that may consist of multiple parts, each part may be of a different type.

Here, for example the input message of the previous operation is:

<wsdl:message name="DictionaryListSoapIn">
  <wsdl:part name="parameters" element="tns:DictionaryList"/>
</wsdl:message>

Then, to understand the content of the message, have a look at the types:

A container for abstract type definitions defined using XML Schema

Here, the DictionaryList element is defined as an empty compleType:

<s:element name="DictionaryList">
  <s:complexType/>
</s:element>

As I said, this is really a very simplified answer as WSDL can't be summarized in four paragraphs and, to be honest, what you are going to do is really not a trivial task. Let me rephrase this: there will be blood! So, even if these few lines may help you (a very little) to get started, I'd definitely not start such a project from scratch but rather use an existing library or tool (like Xydra or Eclipse XML Forms Generator or ...) that would allow to not reinvent the wheel.

By the way, I noticed that you have decided to use Axis and that you don't want to generate the Java classes but I'd warmly recommend to not use Axis anyway. Actually, I'd use JAX-WS RI wich is bundled in Java 6 and is a much easier API. Just in case, to generate the Java classes, just execute:

$ mkdir generated
$ wsimport -d generated http://services.aonaware.com/DictService/DictService.asmx?WSDL
猫弦 2024-08-23 05:27:27

这是 Thomas Bayer 撰写的关于“读取 wsdl 文件”的好教程
http://www.predic8.com/wsdl-reading.htm

here is a good tutorial about "Reading a wsdl file" by Thomas Bayer
http://www.predic8.com/wsdl-reading.htm

廻憶裏菂餘溫 2024-08-23 05:27:27

这不是一个简单的项目,您可能会发现已经执行此操作的库将是您的最佳方法,但起点是将属性映射到 HTML FORM 组件,并将 Min/Max Occues 映射到 JavaScript 事件。

根据您对 WSDL 的理解,编写 FORM 可能会容易得多。至于有帮助的东西,您可以使用类似

http://www.soapui.org/

或对于基于网络的东西(我刚刚使用您的 WSDL 进行了测试并且它有效),您可以尝试

http://www .soapclient.com/soaptest.html

我知道这两个链接可能完全不符合您想要完成的目标,所以祝您在应对这一挑战的过程中好运:)

This is not a trivial project, and you may find that a library that already does this would be your best approach, but places to start would be mapping attributes to HTML FORM components, and the Min/Max Occues to JavaScript events.

It would likely be a lot easier to write your FORM from your understanding of the WSDL. As for something that could help, you could use something like

http://www.soapui.org/

Or for something web based (which I just tested with your WSDL and it works) you can try

http://www.soapclient.com/soaptest.html

I know that these two links might be totally off base for what you are trying to accomplish though, so good luck in your effort to tackle this challenge :)

碍人泪离人颜 2024-08-23 05:27:27

我不能代表 WSDL 方面,但您可以考虑 Metawidget 作为表单生成方面:一旦您提取了并解析了 WSDL,您可以将其推送到 Metawidget 中并免费获得许多 UI 优点(支持不同平台、不同的小部件库等)。

问候,

Richard。

I can't speak for the WSDL side, but you may consider Metawidget for the form generation side: once you've extracted and parsed the WSDL, you can push it into Metawidget and get a lot of UI goodness for free (support for different platforms, different widget libraries, etc.)

Regards,

Richard.

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