简体   繁体   English

如何使用 Python suds 解析 wsdl 的 xml 内容?

[英]How can I parse xml content of wsdl using Python suds?

I'm connecting to wsdl using suds library我正在使用 suds 库连接到 wsdl

from suds.client import Client
url = 'http://localhost:0000/webservices/WebService?wsdl'
client = Client(url)

WSDL contains come xml code: WSDL 包含来 xml 代码:

<wsdl:message name="GetRequest">
    <wsdl:part element="types:GetVersion" name="body"></wsdl:part>
    <wsdl:part element="comm:Credentials" name="credentials"></wsdl:part>
</wsdl:message>

How can I get this xml from wsdl and parse it in python?如何从 wsdl 获取这个 xml 并在 python 中解析它?

I suppose you want to parse the xml in order to get the functions and theirs parameters?我想您想解析 xml 以获取函数及其参数? You already got with the object Client.您已经获得了对象 Client。 If you try, print Client you should get the information you need.如果您尝试print Client您应该会获得所需的信息。 You can also try something like that:你也可以尝试这样的事情:

functions = [m for m in client.wsdl.services[0].ports[0].methods]
    print "functions --> ", functions

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM