Re: Parsing soap result
Hi, On 04/18/13 13:46, Ombongi Moraa Fe wrote: Hi Burak, Team, Apparently I was too deep in answering support questions for my company :) This is python-list, so It's just me here :) Your solution worked perfectly thanks. Could you share the logic of this solution? You're using suds. Let's have a look at what you see: [(DeliveryInformation){ address = "254727" deliveryStatus = "DeliveredToNetwork" }] You have it in square brackets, so it's an array. You apparently want the first element, so it's result[0]. It's of type DeliveryInformation with two fields, they are what you see there. Depending on the which soap mode (rpc/document) your server uses, you should either use result[0].deliveryStatus or result[0].DeliveryInformation.deliveryStatus. I guess I got too much experience doing SOAP with python :) (I maintain spyne, see: http://spyne.io) I'm glad it worked. Best, Burak -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing soap result
Hi Burak, Team, Your solution worked perfectly thanks. Could you share the logic of this solution? Saludos Ombongi Moraa Faith On 18 April 2013 00:41, Burak Arslan wrote: > On 04/17/13 16:50, Ombongi Moraa Fe wrote: > > My > > client.service.gere(ri) > > method call logs the below soap response in my log file. > > http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi=" > http://www.w3.org/2001/XMLSchema-instance";> xmlns:ns1="http://www.csapi.org/schema/parlayx/sms/send/v2_2/local > ">254727DeliveredToNetwork > > > If I assign the client.service.gere(ri) to a variable, i get the output > on my screen: > > result=client.service.gere(ri) > > output: > [(DeliveryInformation){ >address = "254727" >deliveryStatus = "DeliveredToNetwork" > }] > > string functions replace() and strip don't work. > > how do I use xml.etree.ElementTree to print the parameters address and > deliveryStatus? Or is there a better python method? > > > hi, > > try: > > result[0].deliveryStatus > > or > > result[0].DeliveryInformation.deliveryStatus > > > and let us know. > > best, > burak > > -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing soap result
On 04/17/13 16:50, Ombongi Moraa Fe wrote: My client.service.gere(ri) method call logs the below soap response in my log file. xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>xmlns:ns1="http://www.csapi.org/schema/parlayx/sms/send/v2_2/local";>254727DeliveredToNetwork If I assign the client.service.gere(ri) to a variable, i get the output on my screen: result=client.service.gere(ri) output: [(DeliveryInformation){ address = "254727" deliveryStatus = "DeliveredToNetwork" }] string functions replace() and strip don't work. how do I use xml.etree.ElementTree to print the parameters address and deliveryStatus? Or is there a better python method? hi, try: result[0].deliveryStatus or result[0].DeliveryInformation.deliveryStatus and let us know. best, burak -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing soap result
On Apr 17, 1:05 pm, Christian Heimes wrote: > Am 17.04.2013 19:55, schrieb darnold: > > > On Apr 17, 8:50 am, Ombongi Moraa Fe > > wrote: > > >> how do I use xml.etree.ElementTree to print the parameters address and > >> deliveryStatus? Or is there a better python method? > > > I'm sure there are prettier ways to do this, but you can use XPath > > syntax to find all of your ns1:result nodes and loop through them: > > You want all {http://www.csapi.org/schema/parlayx/sms/send/v2_2/ > local}result tags. The prefix isn't fixed. I'm sorry, but I'm not understanding the difference. By specifying: >>> myNamespaces=dict(ns1="http://www.csapi.org/schema/parlayx/sms/send/v2_2/local";) Isn't this: >>> for result in root.findall('.//ns1:result',namespaces=myNamespaces): equivalent to: >>> for result in >>> root.findall('.//{http://www.csapi.org/schema/parlayx/sms/send/v2_2/local}result'): ? Or am I misunderstanding? Is there a namespace-agnostic way of doing this? Admittedly, I haven't used ElementTree or XPath much prior to toying with them to (attempt to) answer the OP's question. Thanks for your patience, Don -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing soap result
Am 17.04.2013 19:55, schrieb darnold: > On Apr 17, 8:50 am, Ombongi Moraa Fe > wrote: > >> how do I use xml.etree.ElementTree to print the parameters address and >> deliveryStatus? Or is there a better python method? >> > > > I'm sure there are prettier ways to do this, but you can use XPath > syntax to find all of your ns1:result nodes and loop through them: You want all {http://www.csapi.org/schema/parlayx/sms/send/v2_2/ local}result tags. The prefix isn't fixed. -- http://mail.python.org/mailman/listinfo/python-list
Re: Parsing soap result
On Apr 17, 8:50 am, Ombongi Moraa Fe wrote: > how do I use xml.etree.ElementTree to print the parameters address and > deliveryStatus? Or is there a better python method? > I'm sure there are prettier ways to do this, but you can use XPath syntax to find all of your ns1:result nodes and loop through them: >>> import xml.etree.ElementTree as ET >>> myXML = '''\ http://schemas.xmlsoap.org/soap/ envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";> http://www.csapi.org/schema/parlayx/sms/send/v2_2/ local"> 254727 DeliveredToNetwork ''' >>> myNamespaces=dict(ns1="http://www.csapi.org/schema/parlayx/sms/send/v2_2/local",soapenv="http://schemas.xmlsoap.org/soap/envelope/";) >>> root = ET.fromstring(myXML) >>> for result in root.findall('.//ns1:result',namespaces=myNamespaces): address = result.find('address').text deliveryStatus = result.find('deliveryStatus').text print "address: %s, deliveryStatus: %s" % (address,deliveryStatus) address: 254727, deliveryStatus: DeliveredToNetwork >>> HTH, Don -- http://mail.python.org/mailman/listinfo/python-list
Parsing soap result
My client.service.gere(ri) method call logs the below soap response in my log file. http://schemas.xmlsoap.org/soap/envelope/"; xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance";>http://www.csapi.org/schema/parlayx/sms/send/v2_2/local ">254727DeliveredToNetwork If I assign the client.service.gere(ri) to a variable, i get the output on my screen: result=client.service.gere(ri) output: [(DeliveryInformation){ address = "254727" deliveryStatus = "DeliveredToNetwork" }] string functions replace() and strip don't work. how do I use xml.etree.ElementTree to print the parameters address and deliveryStatus? Or is there a better python method? Thanks in advance. Saludos Ombongi Moraa Faith -- http://mail.python.org/mailman/listinfo/python-list