Reputation: 627
I converted my SOAP-based WCF web service project to a REST-based one, using the "WCF REST Starter Kit" project templates. My core code hasn't changed, only the wrapper from SOAP to REST. Client says it works and they can consume data. Great.
Problem: client says special characters break their XML parser where it didn't in SOAP. Ex:
<SomeItem>Simon & Simon</SomeItem>
...here the ampersand is the problem. The client is using a Java client but I'm unsure which at the moment.
Since the SOAP version worked fine, is there something special I have to do in my code or .config? A type of encoding specification perhaps? (I know I could write a scrubber method that replaces problematic characters w/ an encoded version prior to returning the result, but I'm hoping there is a built-in encoding specification setting or such).
EDIT: bad example on my part. turns out the & is properly being encoded by WCF REST. what isnt:
<UnitOfMeasure>°F</UnitOfMeasure>
...which I think is not being encoded because ° symbol is not part of XML/HTML syntax and thus doesn't require encoding to prevent invalid syntax. As I understand it.
thanks, matt
Upvotes: 2
Views: 320
Reputation: 13990
Encode your data before returning.
http://msdn.microsoft.com/en-us/library/w3te6wfz.aspx
Best regards
Upvotes: 1