编程语言
首页 > 编程语言> > Python,suds,管理数组答案

Python,suds,管理数组答案

作者:互联网

我正在使用suds库从webservice获取产品列表.

这是一个示例代码:

from suds.client import Client
url = 'WSDLURL'
client = Client(url)
result = client.service.Research('value')

结果包含:

(ArrayOfProducts){
   Product[] = 
      (Product){
         Id = 218
         Code = "C024"
         Name = "test2"
         Avaiable = True
         UrlDownload = None
         MetaData = 
            (ArrayOfMetaData){
               MetaData[] = 
                  (MetaData){
                     CoderepositoryISO = "16701"
                     Title = "1ST"
                  },
            }
      },
      (Product){
         Id = 219
         Code = "C025"
         Name = "test3"
         Avaiable = True
         UrlDownload = None
         MetaData = 
            (ArrayOfMetaData){
               MetaData[] = 
                  (MetaData){
                     CoderepositoryISO = "16702"
                     Title = "2ND"
                  },
            }
      },
...

在python或suds中,有一种方法可以直接访问带有for的产品循环所包含的数据? (例如:Product.Id,Product.Code等)

解决方法:

完美……感谢J.F. Sebastian,我找到了正确的方法……
这是工作代码:

from suds.client import Client
url = 'wsdl'
client = Client(url)
html_out = ""
result = client.service.Research('a')
for p in result.Product:
   print p.Id
   print p.Name

标签:python,arrays,soap,web-services,suds
来源: https://codeday.me/bug/20190621/1256590.html