从 WSDL 生成请求/响应 XML

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/35908226/
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-09-06 12:11:18  来源:igfitidea点击:

Generating Request/Response XML from a WSDL

xmlweb-serviceswsdl

提问by user93353

Is there a way to generate Request & Response XML formats from just a WSDL file - if the webservice is not live right now.

有没有办法仅从 WSDL 文件生成请求和响应 XML 格式 - 如果 web 服务现在不可用。

SoapUI doesn't give me the response unless it contacts the Webservice with a request. Is there any other tool which can do this?

SoapUI 不会给我响应,除非它通过请求联系 Web 服务。有没有其他工具可以做到这一点?

I should assume this information is available - because without it - client stub frameworks like Axis/JAXWS etc won't be able to generate stubs for generating the requesting and then interpreting the response.

我应该假设这些信息是可用的 - 因为没有它 - 像 Axis/JAXWS 等客户端存根框架将无法生成存根来生成请求然后解释响应。

采纳答案by Siderite Zackwehdex

Try this online tool: https://www.wsdl-analyzer.com. It appears to be free and does a lot more than just generate XML for requests and response.

试试这个在线工具:https: //www.wsdl-analyzer.com。它似乎是免费的,而且不仅仅是为请求和响应生成 XML。

There is also this: https://www.oxygenxml.com/xml_editor/wsdl_soap_analyzer.html, which can be downloaded, but notfree.

还有这个:https: //www.oxygenxml.com/xml_editor/wsdl_soap_analyzer.html,可以下载,但不是免费的。

回答by Abhishek Chaturvedi

I use SOAPUI 5.3.0, it has an option for creating requests/responses (also using WSDL), you can even create a mock service which will respond when you send request. Procedure is as follows:

我使用SOAPUI 5.3.0,它有一个用于创建请求/响应的选项(也使用 WSDL),您甚至可以创建一个模拟服务,该服务将在您发送请求时做出响应。程序如下:

  1. Right click on your project and select New Mock Service option which will create mock service.
  2. Right click on mock service and select New Mock Operation option which will create response which you can use as template.
  1. 右键单击您的项目并选择 New Mock Service 选项,这将创建模拟服务。
  2. 右键单击模拟服务并选择新建模拟操作选项,这将创建您可以用作模板的响应。


EDIT #1:

编辑#1:

Check out the SoapUI linkfor the latest version. There is a Pro version as well as the free open source version.

查看最新版本的SoapUI 链接。有专业版和免费开源版。

回答by rachid el kedmiri

The easiest way is to use this chrome extension link, happy web service requesting

最简单的方法是使用这个chrome扩展链接,快乐web服务请求

回答by MikeC

Doing this yourself will give you insight into how a WSDL is structured and how it gets your job done. It is a good learning opportunity. This can be done using soapUI, if you only have the URL of the WSDL. (I'm using soapUI 5.2.1) If you actually have the complete WSDL as a file available to you, you don't even need soapUI. The title of the question says "Request & Response XML" while the question body says "Request & Response XML formats" which I interpret as the schema of the request and response. At any rate, the following will give you the schema which you can use on XSD2XMLto generate sample XML.

自己执行此操作将使您深入了解 WSDL 的结构以及它如何完成您的工作。这是一个很好的学习机会。如果您只有 WSDL 的 URL,则可以使用 soapUI 完成此操作。(我使用的是soapUI 5.2.1)如果您确实将完整的WSDL 作为文件提供给您,那么您甚至不需要soapUI。问题的标题说“请求和响应 XML”,而问题正文说“请求和响应 XML 格式”,我将其解释为请求和响应的模式。无论如何,以下内容将为您提供可以在XSD2XML上使用以生成示例 XML 的模式。

  1. Start a "New Soap Project", enter a project name and WSDL location; choose to "Create Requests", unselect the other options and click OK.
  2. Under the "Project" tree on the left side, right-click an interface and choose "Show Interface Viewer".
  3. Select the "WSDL Content" tab.
  4. You should see the WSDL text on the right hand side; look for the block starting with "wsdl:types" below which are the schema for the input and output messages.
  5. Each schema definition starts with something like <s:element name="GetWeather">and ends with </s:element>.
  6. Copy out the block into a text editor; above this block add: <?xml version="1.0" encoding="UTF-8"?> <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  7. Below the block of copied XML, add </s:schema>
  8. Decide if you need "UTF-16" instead of "UTF-8"
  9. The "s:" and the "xmlns:s" should match the block you copied (step 5)
  10. Save this file with ".xsd" extension; if you have "XML Copy Editor" or some such tool (XML Spy, may be) you should check that this is well-formed XML and valid schema.
  11. Repeat for all "element" items in the right hand pane of soapUI until you reach
  12. This way you'll get some type definitions you might not be interested in. If you want to pick and choose, use the following method: Look through the "wsdl:operation" items under "wsdl:portType" in the WSDL text below the type definitions. They will have "wsdl:input" and "wsdl:output". Take the message names from "wsdl:input" and "wsdl:output". Match them against "wsdl:message" names which will likely be above the "wsdl:portType" entries in the WSDL. Get the "wsdl:part" element name from "wsdl:message" item and look for that name as element name under "wsdl:types". Those will be the schema of interest to you.
  1. 启动一个“New Soap Project”,输入项目名称和WSDL位置;选择“创建请求”,取消选择其他选项,然后单击“确定”。
  2. 在左侧的“项目”树下,右键单击一个接口并选择“显示接口查看器”。
  3. 选择“WSDL 内容”选项卡。
  4. 您应该会在右侧看到 WSDL 文本;查找以“wsdl:types”开头的块,下面是输入和输出消息的模式。
  5. 每个模式定义都以类似开头<s:element name="GetWeather">并以</s:element>.
  6. 将块复制到文本编辑器中;在此块上方添加: <?xml version="1.0" encoding="UTF-8"?> <s:schema xmlns:s="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
  7. 在复制的 XML 块下方,添加 </s:schema>
  8. 决定是否需要“UTF-16”而不是“UTF-8”
  9. "s:" 和 "xmlns:s" 应该与您复制的块匹配(第 5 步)
  10. 使用“.xsd”扩展名保存此文件;如果您有“XML Copy Editor”或一些此类工具(可能是 XML Spy),您应该检查这是格式正确的 XML 和有效的模式。
  11. 对soapUI 右侧窗格中的所有“元素”项重复,直到到达
  12. 通过这种方式,您将获得一些您可能不感兴趣的类型定义。如果您想挑选和选择,请使用以下方法:查看下方 WSDL 文本中“wsdl:portType”下的“wsdl:operation”项类型定义。他们将有“wsdl:input”和“wsdl:output”。从“wsdl:input”和“wsdl:output”中获取消息名称。将它们与可能位于 WSDL 中“wsdl:portType”条目上方的“wsdl:message”名称相匹配。从“wsdl:message”项中获取“wsdl:part”元素名称,并在“wsdl:types”下查找该名称作为元素名称。这些将是您感兴趣的模式。

You can try above procedure out using the WSDL at http://www.webservicex.com/globalweather.asmx?wsdl

您可以使用http://www.webservicex.com/globalweather.asmx?wsdl 上的 WSDL 尝试上述过程

回答by Samuel Garratt

Parasoft is a tool which can do this. I've done this very thing using this tool in my past work place. You can generate a request in Parasoft SOATest and get a response in Parasoft Virtualize. It does cost though. However Parasoft Virtualize now has a free community edition from which you can generate response messages from a WSDL. You can download from parasoft community edition

Parasoft 是一个可以做到这一点的工具。我在过去的工作场所使用这个工具完成了这件事。您可以在 Parasoft SOATest 中生成请求并在 Parasoft Virtualize 中获得响应。虽然它确实成本。然而,Parasoft Virtualize 现在有一个免费的社区版,您可以从中生成来自 WSDL 的响应消息。您可以从parasoft 社区版下载

回答by ChanGan

Since you are saying the webservice is not live right now, you can do it by creating mockservices which will create the sample response format.

由于您说 web 服务现在不可用,您可以通过创建模拟服务来创建示例响应格式。

回答by A_J

To test your WSDL file online links are :

要测试您的 WSDL 文件在线链接是:

https://wsdlbrowser.com/

https://wsdlbrowser.com/

https://wsdlanalyzer.com/

https://wsdlanalyzer.com/