开发者

Python, suds, manage array answer

I'm using suds library to fetch a list of products from a webservice.

This is a sample code:

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

Result contains:

(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"
                  },
            }
      },
...
开发者_JAVA百科

There is a way, in python or suds, to access directly to the contained data cycling on the products with a for? (e.g.: Product.Id, Product.Code, etc.)


Perfect... Thanks to J.F. Sebastian I find the right way... This is the working code:

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜