Python SOAP 服务器/客户端 [英] Python SOAP server / client

查看:50
本文介绍了Python SOAP 服务器/客户端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用 Python 和 SOAP 时遇到问题.我需要在 Python 中创建一个基于 SOAP 的 Web 服务.我读到我可以使用诸如soaplib、suds 和ZSI 之类的库.我使用soaplib 创建了一个Hello World Web 服务,就像在文档(http://trac.optio.webfactional.com/wiki/HelloWorld).问题是我无法为使用soaplib 库以外的Web 服务创建客户端.我想使用 Python 中的 suds 库来制作客户端应用程序.

I have a problem with Python and SOAP. I need to create a web service based on SOAP in Python. I read that I can use libraries like soaplib, suds and ZSI. I created a Hello World web service with soaplib, like in documentation (http://trac.optio.webfactional.com/wiki/HelloWorld). The problem is that I cannot make a client for the web service which uses other than soaplib library. I wanted to do the client app using for example suds library in Python.

您是否设法使用 Python 中的应用程序(例如使用 suds 库)使用 Python 中的 soaplib 创建的 SOAP 网络服务?

Did you managed to do an application in Python (for example with suds library) consuming the SOAP web service created with soaplib in Python?

推荐答案

您如何提供服务?soaplib 生成一个 WSGI 对象,它需要由网络服务器提供服务.如果您正在关注链接到的 helloworld 示例,那么您正在使用 CherryPy(纯 Python Web 服务器)在您自己的机器上托管服务.在示例中,端口是 7789(但您可以使用任何您喜欢的端口).因此,如果您使用该示例,您应该首先启动运行cherrypy 的脚本——这应该保持运行并且不会返回到提示.当它运行时,您应该能够通过 http://localhost:7789/wsdl 访问您的服务 - 您可以将该地址放入 Web 浏览器以查看它是否正常工作.只要 url 以 wsdl 结尾,Soaplib 就会返回 wsdl - 所以实际上你可以做 http://localhost:7789/anythingherewsdl.

How are you serving the service? soaplib produces a WSGI object, which needs to be served by a webserver. If you are following the helloworld example you link to then you are using CherryPy (a pure python web server) to host the service on your own machine. In the example the port is 7789 (but you can use anything you like). So if you use the example you should first start the script which runs cherrypy - this should stay running and not return to the prompt. When that is running you should be able to access your service at http://localhost:7789/wsdl - you can put that address in a web browser to see if it is working. Soaplib returns the wsdl as long as the url ends in wsdl - so in fact you can do http://localhost:7789/anythingherewsdl.

这篇关于Python SOAP 服务器/客户端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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