Xlms namespace

sohcahtoa82 at gmail.com sohcahtoa82 at gmail.com
Wed Apr 20 13:52:12 EDT 2016


On Wednesday, April 20, 2016 at 10:05:02 AM UTC-7, Joaquin Alzola wrote:
> Hi Guys
> 
> I am currently doing this:
> 
> IP client(Python) --> send SOAPXML request --> IP Server (Python)
> 
> SOAP request:
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:req="http:/
> /request.messagepush.interfaces.comviva.com" xmlns:xsd="http://request.messagepush.interfaces
> .comviva.com/xsd">
> <xsd:text>test\ntest\ntest<{[£ EURO&%]}></xsd:text>
> 
> From my IP Client:
> s.send(data_send.encode('utf-8'))
> 
> From my IPServer:
> xml_decoded = data.decode('utf-8')
>                               xml_root = ET.ElementTree(ET.fromstring(xml_decoded)).getroot()
>                               for elem in xml_root.getiterator():
>                                              if('{http://request.messagepush.interfaces.comviva.com/xsd}shortCode'==elem.tag):
>                                                             shortCode = (elem.text).rstrip()
>                                              if('{http://request.messagepush.interfaces.comviva.com/xsd}text'==elem.tag):
>                                                             send_text = (elem.text).rstrip()
>                                              if('{http://request.messagepush.interfaces.comviva.com/xsd}item'==elem.tag):
>                                                             subscribers = (elem.text).rstrip()
>                               result_sms = send_sms(subscribers,shortCode,send_text)
> 
> It is working fine but I am having problems with a couple of special characters, & and <
> 
> The problem:
> <xsd:text>test\ntest\ntest<{[£ EURO&%]}></xsd:text>
> 
> It seems as if I send this: <> and the character & then I have a problem.
> I need to use utf-8 as I need to make sure I get 160 characters in one SMS.
> 
> Error:
> Traceback (most recent call last):
>   File "./ipserver.py", line 52, in <module>
>     main()
>   File "./ipserver.py", line 36, in main
>     xml_root = ET.ElementTree(ET.fromstring(xml_decoded)).getroot()
>   File "/usr/lib64/python3.4/xml/etree/ElementTree.py", line 1325, in XML
>     parser.feed(text)
> xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 19, column 48
> This email is confidential and may be subject to privilege. If you are not the intended recipient, please do not copy or disclose its content but contact the sender immediately upon receipt.

If I had to make a guess, you need to escape the <, >, and &characters or else they'll get parsed by the XML parser.  Try sending "<xsd:text>test\ntest\ntest<{[£ EURO&%]}></xsd:text>"



More information about the Python-list mailing list