我们使用自定义序列化模式来对象的xml序列化。我有一个使用WCF服务Tempalte编写的WCF REST服务。我想从这个方法返回我们的自定义XML,但是当我将返回设置为字符串时,我得到了这个:
<string xmlns="http://schemas.microsoft.com/2003/10/Serialization/">
<?xml version="1.0" encoding="utf-16"?><ReportResponse><Status>Success</Status><Url>http://pictor.blob.core.windows.net/pictor/ServiceTest.pdf</Url><ReportRequestId>00000000-0000-0000-0000-000000000000</ReportRequestId></ReportResponse>
</string>
正如您所看到的,我的xml被包装在一个html编码的字符串中..如何返回相应的xml响应?
答案 0 :(得分:1)
使用XElement作为响应类型允许我返回我选择的任何xml。 这个答案归功于@Mark Gravell。