[Fedora-suds-list] suds.sax.text.Text howto

jo jose.soares at sferacarta.com
Wed Oct 26 13:20:45 UTC 2011


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
>
> 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)
>>     
> _______________________________________________
> suds mailing list
> suds at lists.fedoraproject.org
> https://admin.fedoraproject.org/mailman/listinfo/suds
>   


-- 
Jose Soares
Sferacarta Net 
Via Bazzanese 69
40033 Casalecchio di Reno
Bologna - Italy
Ph  +39051591054
fax +390516131537
web:www.sferacarta.com

Le informazioni contenute nella presente mail ed in ogni eventuale file allegato sono riservate e, comunque, destinate esclusivamente alla persona o ente sopraindicati, ai sensi del decreto legislativo 30 giugno 2003, n. 196. La diffusione, distribuzione e/o copiatura della mail trasmessa, da parte di qualsiasi soggetto diverso dal destinatario, sono vietate. La correttezza, l’integrità e la sicurezza della presente mail non possono essere garantite. Se avete ricevuto questa mail per errore, Vi preghiamo di contattarci immediatamente e di eliminarla. Grazie.

This communication is intended only for use by the addressee, pursuant to legislative decree 30 June 2003, n. 196. It may contain confidential or privileged information. You should not copy or use it to disclose its contents to any other person. Transmission cannot be guaranteed to be error-free, complete and secure. If you are not the intended recipient and receive this communication unintentionally, please inform us immediately and then delete this message from your system. Thank you.



More information about the suds mailing list