Hi all,
I'm arguing with an object sax and I can't extract the values from it. Someone could please give me some help?
(Pdb) type(result) <class 'suds.sax.text.Text'>
(Pdb) result <?xml version="1.0" encoding="UTF-8"?> <Output> <OpenSession> <SessionID>1e0000001333f3e9185</SessionID> <user>VETER</user> <nome>VETERINARI</nome> <azienda>0112</azienda> <ufficio>1G12</ufficio> <ruolo>GC21</ruolo> <dataLavoro>20111026</dataLavoro> <entita>FO211212</entita> </OpenSession> </Output>
thanks j
from suds.client import Client url='http://172.28.32.185:8082/demone1/jbfServices/JBFService?wsdl' client = Client(url)
par=dict( user='VETER', password='1INTE', azienda='0112', ufficio='1G12', ruolo='GC21', entita='FO211212')
xml=""" <Input> <OpenSession> <user>%(user)s</user> <password>%(password)s</password> <azienda>%(azienda)s</azienda> <ufficio>%(ufficio)s</ufficio> <ruolo>%(ruolo)s</ruolo> <entita>%(entita)s</entita> </OpenSession> </Input> """ % par
result = client.service.call(xml)
Hi, it seems to me that the web service you're using returned an XML as a string (which is not pretty, but I encountered this "solution" several times) -- you did the same with the parameter. You should parse the XML _again_ (e.g. by lxml) and use that. As the sample you sent uses a private IP address, I'll show you an example using a public service that also uses this ugly technique.
from suds.client import Client c = Client('http://www.mnb.hu/arfolyamok.asmx?WSDL') rates = c.service.GetCurrentExchangeRates() type(rates)
<class 'suds.sax.text.Text'>
from lxml import etree tree = etree.fromstring(rates) tree.xpath('/MNBCurrentExchangeRates/Day/Rate[@curr="EUR"]/text()')
['298,63']
Regards, András Veres-Szentkirályi
2011. október 26. szerda 10:11:42 dátummal jo ezt írta:
Hi all,
I'm arguing with an object sax and I can't extract the values from it. Someone could please give me some help?
(Pdb) type(result) <class 'suds.sax.text.Text'>
(Pdb) result
<?xml version="1.0" encoding="UTF-8"?>
<Output> <OpenSession> <SessionID>1e0000001333f3e9185</SessionID> <user>VETER</user> <nome>VETERINARI</nome> <azienda>0112</azienda> <ufficio>1G12</ufficio> <ruolo>GC21</ruolo> <dataLavoro>20111026</dataLavoro> <entita>FO211212</entita> </OpenSession> </Output>
thanks j
from suds.client import Client url='http://172.28.32.185:8082/demone1/jbfServices/JBFService?wsdl' client = Client(url)
par=dict( user='VETER', password='1INTE', azienda='0112', ufficio='1G12', ruolo='GC21', entita='FO211212')
xml=""" <Input> <OpenSession> <user>%(user)s</user> <password>%(password)s</password> <azienda>%(azienda)s</azienda> <ufficio>%(ufficio)s</ufficio> <ruolo>%(ruolo)s</ruolo> <entita>%(entita)s</entita> </OpenSession> </Input> """ % par
result = client.service.call(xml)
Thanks, Andras, it works! j
Veres-Szentkiralyi Andras wrote:
Hi, it seems to me that the web service you're using returned an XML as a string (which is not pretty, but I encountered this "solution" several times) -- you did the same with the parameter. You should parse the XML _again_ (e.g. by lxml) and use that. As the sample you sent uses a private IP address, I'll show you an example using a public service that also uses this ugly technique.
from suds.client import Client c = Client('http://www.mnb.hu/arfolyamok.asmx?WSDL') rates = c.service.GetCurrentExchangeRates() type(rates)
<class 'suds.sax.text.Text'>
from lxml import etree tree = etree.fromstring(rates) tree.xpath('/MNBCurrentExchangeRates/Day/Rate[@curr="EUR"]/text()')
['298,63']
Regards, András Veres-Szentkirályi
- október 26. szerda 10:11:42 dátummal jo ezt írta:
Hi all,
I'm arguing with an object sax and I can't extract the values from it. Someone could please give me some help?
(Pdb) type(result) <class 'suds.sax.text.Text'>
(Pdb) result
<?xml version="1.0" encoding="UTF-8"?>
<Output> <OpenSession> <SessionID>1e0000001333f3e9185</SessionID> <user>VETER</user> <nome>VETERINARI</nome> <azienda>0112</azienda> <ufficio>1G12</ufficio> <ruolo>GC21</ruolo> <dataLavoro>20111026</dataLavoro> <entita>FO211212</entita> </OpenSession> </Output>
thanks j
from suds.client import Client url='http://172.28.32.185:8082/demone1/jbfServices/JBFService?wsdl' client = Client(url)
par=dict( user='VETER', password='1INTE', azienda='0112', ufficio='1G12', ruolo='GC21', entita='FO211212')
xml=""" <Input> <OpenSession> <user>%(user)s</user> <password>%(password)s</password> <azienda>%(azienda)s</azienda> <ufficio>%(ufficio)s</ufficio> <ruolo>%(ruolo)s</ruolo> <entita>%(entita)s</entita> </OpenSession> </Input> """ % par
result = client.service.call(xml)
suds mailing list suds@lists.fedoraproject.org https://admin.fedoraproject.org/mailman/listinfo/suds