使用捕获的流量为现有 SOAP 服务生成 WSDL [英] Generate WSDL for existing SOAP Service using captured traffic

查看:26
本文介绍了使用捕获的流量为现有 SOAP 服务生成 WSDL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用打印机的 SOAP 服务.有一个 Windows 工具可以访问此服务,我用它来生成 SOAP 请求和我需要的重要功能的响应.

I need to use the SOAP service of a printer. There is a windows tool to access this service and I used it to generate SOAP requests and responses of the important functions that I need.

现在我应该使用 Python 为 Linux 编写一个客户端,我发现最简单的方法是使用带有 WSDL 文件的 suds 库.但是我没有这个 WSDL!

Now I should write a client for Linux using Python and I found the easiest way would be to use the suds library with an WSDL file. But I don't have this WSDL!

当我调查 windows 工具(查看可执行文件的 hexdump)时,我得出的结论是可能根本没有 WSDL 文件.

As I investigated the windows tool (looked at the hexdump of the executables), I came to the conclusion that there probably is no WSDL file at all.

现在我的问题是,有没有人使用过逆向工程"SOAP 服务并且知道对于为现有服务创建 WSDL 文件可能有用的工具吗?(Googleing 还没有提出任何有用的东西).

Now my question is, has anybody experience with "reverse engineering" SOAP services and knows tools which could be useful for creating WSDL files for existing services? (Googleing hasn't brought up anything useful yet).

推荐答案

您提到这是打印机的 SOAP 服务.打印机的 API 是否记录在制造商的网站上?文档是否包含 WSDL?你能从制造商那里得到 WSDL 吗?

You mentioned this is the SOAP service of a printer. Is the printer's API documented on the manufacturer's site? Does the documentation include the WSDL? Can you get the WSDL from the manufacturer?

如果您可以从制造商那里获得 WSDL,那么您就大功告成了!

If you can get the WSDL from the manufacturer then you're done!

如果没有,那么您必须自己构建 WSDL,因为我怀疑您是否可以找到一种工具来生成给定 SOAP 示例的 WSDL(在使用 SOAP Web 服务时,您主要获得两种工具:那些从 WSDL 生成代码的工具+ 从代码生成 WSDL 的那些).

If not, then you have to build the WSDL by yourself because I doubt you can find a tool that generates WSDLs given SOAP samples (when working with SOAP web services you mainly get two kinds of tools: those that generate code from WSDL + those that generate WSDL from code).

如果您熟悉 SOAP、WSDL 和 XSD,那么创建 WSDL 并不难.您只需要一个文本编辑器,甚至可能需要一个 WSDL 编辑器来加快速度.

It's not hard to create the WSDL if you are familiar with SOAP, WSDL and XSD. You just need a text editor or maybe even a WSDL editor to speed things up.

如果您对自己的 WSDL 知识没有完全的信心,仍然有一些工具可以帮助您完成 WSDL 的大部分工作.您可以这样做:

If you don't have full confidence in your WSDL knowledge, there are still some tools that can get you most of the way to the complete WSDL. Here is a way you could do it:

1 - 首先,您需要为SOAP 有效负载.为此,您可以找到工具,甚至一些在线.获得架构后,通过添加、更改或删除元素来根据您的需要对其进行调整.

1 - First you need to create the XML schema for the SOAP payloads. For this you can find tools, even some online. After you have the schema, tweak it to your needs by adding, changing or removing elements.

2 - 现在您可以使用 XSD 生成 WSDL.有一个在线工具可以做到这一点.它只需要请求/响应元素类型以请求/响应结尾.请务必阅读说明.

2 - Now you can use the XSD to generate a WSDL. There is an online tool that does that. It just needs the request/response element types to end with Request/Response. Make sure you read the instructions.

您获取 XSD 文件,更改操作名称以添加 Request/Response 后缀并将其提供给 WSDL Generator - Web 工具.您将获得 WSDL.

You take your XSD file, change the names of the operations to add the Request/Response suffix and feed it to the WSDL Generator - Web Tool. You will get your WSDL.

现在根据需要调整此 WSDL(如果不需要,请删除 Request/Response 后缀)然后...

Now tweak this WSDL as you like (remove the Request/Response suffixes if you don't need them) then ...

3 - ... 确保您最终获得有效的 WSDL.

3 - ... make sure you end up with a valid WSDL.

4 - 现在您可以使用 WSDL 并使用像 SoapUI 这样的工具来生成示例请求和只是为了验证您是否得到了正确的结果.

4 - Now you can take your WSDL and use a tool like SoapUI to generate sample requests and responses from it just to verify that you get the proper results back.

SoapUI 消息是否与您开始使用的消息匹配?如果是,您就完成了,可以将 WSDL 提供给 suds 以创建 Linux 客户端.如果没有,请调整 WSDL,直到得到您想要的结果.

Do the SoapUI messages match the messages you started with? If yes, you are done and can feed the WSDL to suds to create the Linux client. If not, tweak the WSDL until you get the result you are after.

这篇关于使用捕获的流量为现有 SOAP 服务生成 WSDL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆