Is it possible to override a setting in WCF to prevent HTML encoding characters in a response string?
I have a simple service that is called by a third party tool via a SOAP call. The response object has a single property consisting of a string which will contain XML. When WCF packages up the response, it becomes:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<HttpPostResponse xmlns="http://ws.lenderprise.com">
<HttpPostResult>
<STAT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<RESPONSE Attr1="1"
Attr2="ABC"
</RESPONSE>
</STAT>
</HttpPostResult>
</HttpPostResponse>
Is it possible to not have the contained string encoded?
<?xml version="1.0" encoding="ISO-8859-1" ?>
<HttpPostResponse xmlns="http://ws.lenderprise.com">
<HttpPostResult>
<STAT xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<RESPONSE Attr1="1"
Attr2="ABC">
</RESPONSE>
</STAT>
</HttpPostResult>
</HttpPostResponse>
I understand this still leaves me on the hook for ensuring any embedded characters are handled and that this still implies considerations on the receiving end.
If you want to return XML instead of a string, then you can use either XElement
or XmlElement
as your return type. In that case it will not be encoded as a string would.