Parse WSDL with Zeep

心不动则不痛 提交于 2019-12-13 12:14:02

问题


I want to parse a WSDL file with Zeep and get out:

  • All the operations
  • Request xml messages for each operations

Any examples on parsing the wsdl?

I guess I should use zeep.wsdl and the parse_service method?

/A


回答1:


updated:

import operator
from zeep import Client

wsdl = 'http://www.soapclient.com/xml/soapresponder.wsdl'
client = Client(wsdl=wsdl)
for service in client.wsdl.services.values():
    print "service:", service.name
    for port in service.ports.values():
        operations = sorted(
            port.binding._operations.values(),
            key=operator.attrgetter('name'))

        for operation in operations:
            print "method :", operation.name
            print "  input :", operation.input.signature()
            print "  output:", operation.output.signature()
            print
    print



回答2:


solved:

client= Client('url_to_wsdl')
for service in client.wsdl.services.values():
    for port in service.ports.values():
        operations = sorted(
        port.binding._operations.values(),
        key=operator.attrgetter('name'))

        for operation in operations:
           print operation.name
           node = client.create_message(client.service, operation.name)
           print node


来源:https://stackoverflow.com/questions/44885439/parse-wsdl-with-zeep

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!