问题描述
限时送ChatGPT账号..是否可以覆盖 WCF 中的设置以防止响应字符串中的 HTML 编码字符?
Is it possible to override a setting in WCF to prevent HTML encoding characters in a response string?
我有一个由第三方工具通过 SOAP 调用调用的简单服务.响应对象有一个由包含 XML 的字符串组成的属性.当 WCF 打包响应时,它变成:
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">
<HttpPostResult>
<STAT xmlns:xsi="http://www.w3/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">
<HttpPostResult>
<STAT xmlns:xsi="http://www.w3/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.
推荐答案
如果你想返回 XML 而不是字符串,那么你可以使用 XElement
或 XmlElement
作为您的返回类型.在这种情况下,它不会被编码为字符串.
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.
这篇关于防止 WCF 在响应中编码字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论