【问题标题】:Parse WSDL with Zeep使用 Zeep 解析 WSDL
【发布时间】:2017-07-03 12:20:30
【问题描述】:

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

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

有没有解析wsdl的例子?

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

/A

【问题讨论】:

    标签: zeep


    【解决方案1】:

    更新:

    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】:

      已解决:

      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
      

      【讨论】:

      • evenn strong @dan-h 在你之前做出了回应,你已经接受了你自己的答案,复制了他的。为你感到羞耻
      • @ilhnctn 我错过了什么吗? Dan H 比这个答案晚了两个月。
      • 哎呀.. 真的很抱歉。我刚刚看到“17 年 4 月 8 点 32 分”部分,它们几乎是一样的 :( 真丢脸,我道歉。
      • @ilhnctn 它发生了。但我希望你没有因此而投反对票。
      • 不幸的是我做到了,但在编辑答案之前它不允许我投票,你能回答吗?将括号添加到打印功能就足够了:)
      猜你喜欢
      • 2018-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多