使用Python从WSDL文件创建模拟Web服务 [英] Creating a mock web service from a WSDL file in Python

查看:319
本文介绍了使用Python从WSDL文件创建模拟Web服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为远程服务编写一个客户端,该客户端公开SOAP Web服务并发布这些服务的WSDL定义.

We are writing a client for a remote service that exposes SOAP web services and publishes a WSDL definition for those services.

我们在测试期间无权访问系统,因此我们想编写一个模拟服务.我们正在使用Python作为客户端,因此理想情况下,我们希望将Python用于模拟服务器,尽管我认为这不是严格必要的.

We don't have access to the system during testing, so we'd like to write a mock service. We're using Python for the client, so ideally we'd want to use Python for the mock server, although I suppose it's not strictly necessary.

梦想是能够从我们可以填充的WSDL文件中生成存根,然后为使用Paste Deploy作为WSGI服务器提供服务的存根,尽管只要是Paste Deploy或WSGI,就不必它工作可靠.最主要的是,我们需要从真实的" WSDL文件生成存根,以便我们不会意外地编写不兼容的模拟服务器.

The dream would be to be able to generate stubs from the WSDL file which we could fill in, and then serve those using Paste Deploy as a WSGI server, although it doesn't have to be Paste Deploy or WSGI so long as it works reliably. The main thing is that we need to be generating the stubs from the "real" WSDL file so that we don't accidentally write a non-compliant mock server.

我们正在将suds用于客户端库,并研究了soaplib和ZSI.但是,soaplib中的wsgi2py内容在顶部表示请勿使用",而ZSI似乎要吞下很多.人们通常用这种东西做什么?

We're using suds for the client side library, and have looked at soaplib and ZSI. However, the wsgi2py stuff in soaplib says "do not use" at the top and ZSI seems like a lot to swallow. What do people generally use for this kind of thing?

马丁

推荐答案

作为模拟服务器,我真的建议soapUI( http: //www.soapui.org ).

As a mock server I would really recommend soapUI (http://www.soapui.org).

它需要一个WSDL并自动生成服务和服务方法.然后,您可以继续使用Groovy脚本定义静态收益或动态收益. 在此处中查看.

It takes a WSDL and generates the services and service methods automatically. You can then go on and define static returns or dynamic ones using Groovy scripts. Take a look here for the documentation of web service mocking.

soapUI提供免费和付费的专业版.我已经成功地使用了免费版本.

soapUI comes in a free and paid pro version. I have used the free version with great success.

这篇关于使用Python从WSDL文件创建模拟Web服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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