Python SOAP 文档处理
我一直在尝试使用 Python 的 suds 来调用 SOAP WSDL。 我只需要以编程方式调用该服务并编写输出 XML 文档。 然而,suds 会自动将此数据解析为其自己的 pythonic 数据格式。 我一直在查看示例和文档,但我似乎找不到返回 SOAP 服务为我提供的 XML 文档的方法。
有没有一种简单的方法可以做到这一点,我忽略了? 在 Python 中是否有比 suds 更简单的方法?
I've been trying to use suds for Python to call a SOAP WSDL. I just need to call the service programmatically and write the output XML document. However suds automatically parses this data into it's own pythonic data format. I've been looking through the examples and the documentation, but I can't seem to find a way to return the XML document that the SOAP service gives me.
Is there an easy way to do this I'm overlooking? Is there an easier way to do this in Python than suds?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 suds 开发的早期阶段,获取原始 XML 内容的最简单方法并不是人们所期望的。
网站上的示例向我们展示了这样的内容:
但是,结果是一个预解析的对象,非常适合 Python 访问,但不适合 XML 文档访问。 幸运的是,Client 对象仍然存储了接收到的原始 SOAP 消息。
将为您提供收到的实际 SOAP 消息。
At this early stage in suds development, the easiest way to get to the raw XML content is not what one would expect.
The examples on the site show us with something like this:
however, the result is a pre-parsed object that is great for access by Python, but not for XML document access. Fortunately the Client object still has the original SOAP message received stored.
Will give you the actual SOAP message received back.
您可以查看诸如 soaplib 之类的库:它是一种非常好的使用方式(和服务)Python 中的 SOAP Web 服务。 最新版本有一些代码可以动态(在运行时)或静态(针对某些 WSDL 运行脚本)动态生成 Python 绑定。
[免责声明:我是该项目的维护者! - 虽然大部分内容不是我写的]
You could take a look at a library such as soaplib: its a really nice way to consume (and serve) SOAP webservices in Python. The latest version has some code to dynamically generate Python bindings either dynamically (at runtime) or statically (run a script against some WSDL).
[disclaimer: I'm the maintainer of the project! - I didn't write the bulk of it though]