We have a web service that is using document/literal message encoding. Several values returned from the web service could contain “special” characters, such as greater than (>) or less than (<). There are two approaches that I am aware of for dealing with these special characters. 1) Wrap the data in a CDATA section 2) Escape the characters by changing them to > and <.
Are there any other approaches that I missed?
I am wondering if there is a recommended approach to dealing with these special characters. Do you recommend using CDATA or escaping them?
If CDATA is the recommendation, do you recommend always adding the CDATA section or only adding the CDATA section if the data being transferred contains a “special” character? This is really a performance question of the overhead of checking for special characters versus transferring and parsing the unneeded CDATA section.