3

我想用 Zeep 解析一个 WSDL 文件并退出:

  • 所有的操作
  • 为每个操作请求 xml 消息

有关解析 wsdl 的任何示例?

我想我应该使用 zeep.wsdl 和 parse_service 方法?

/一个

4

2 回答 2

8

更新:

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
于 2017-09-14T03:06:08.750 回答
4

解决了:

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
于 2017-07-04T08:32:05.943 回答