AnsweredAssumed Answered

Webservice - using doSelect method with python

Question asked by carvato on Mar 28, 2018
Latest reply on Apr 23, 2018 by carvato

Hello everybody, I'm trying to consume the WS method doSelect, in SOAPUI and I make this query

 

       <sid>sid</sid>
      <objectType>cr</objectType>
      <whereClause>open_date > 1519862400 AND open_date &lt; 1522368000
      </whereClause>
      <maxRows>-1</maxRows>
      <attributes>
      <!--1 or more repetitions:-->
     <string>ref_num</string>
    <string>open_date</string>
    </attributes>

And it works perfectly, returns me what I want, but now is my problem, when I try to use that method in Python, I have this class 

 

from zeep import Client
from bs4 import BeautifulSoup


class WebService:

soap = 'Web Service URL'

client = Client(soap)

sid = client.service.login("username","pass")
attributes = ['ref_num', 'open_date']
objectType = "cr"
whereClause = "open_date > 1519862400 AND open_date &lt; 1522368000"
maxRows = -1
tickets = client.service.doSelect(sid=sid, objectType=objectType, whereClause= whereClause, maxRows = maxRows, attributes=attributes)

soup = BeautifulSoup(minim, 'xml')
title = soup.find_all('AttrValue')
print(titile)
client.service.logout(p)

 

It's works, but only read the first string of the array or the position what I tell to read, for example

 

tickets = client.service.doSelect(sid=sid, objectType=objectType, whereClause= whereClause, maxRows = maxRows, attributes=attributes[1])

 

there are no problem, but if I change again the variable for this:

 

tickets = client.service.doSelect(sid=sid, objectType=objectType, whereClause= whereClause, maxRows = maxRows, attributes=str(attributes[ : ]))

 

the method is always null in title, because the AttrValue is

<AttrValue>'ref_num', 'open_date'</AttrValue>

 

zeep is a class to connect to a WS and BeautifulSoup for read XML files, someone can help me?, somebody know other way to consume WS method?

Forwards thanks!

Outcomes