I am working on an iPhone application that requires the use of a third part SOAP web service (I know, SOAP is not preferred, it is just what I am stuck with). Basically user entered data is sent to the web service and I am finding that certain characters will not send and cause the error message below. The one character that causes this that I have run into so far is < . Without the characters it works fine. I want to have the ability to send such characters. I am sending the string with UTF8StringEncoding. Perhaps there is something I can modify to allow such characters?
[req setHTTPBody: [soapMsg dataUsingEncoding:NSUTF8StringEncoding]];
Error:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Sender</faultcode><faultstring>Invalid XML</faultstring></SOAP-ENV:Fault></SOAP-ENV:Body></SOAP-ENV:Envelope>
Seems I have figured this out! So to send the user’s input that include
<, I simply send it with:Using the CDATA tag allows the string pass through as a soap message.