【发布时间】:2016-11-28 20:12:19
【问题描述】:
WCF 为 ServiceContract 的 WebGet 注释中的 ResponseFormat 属性提供了两个选项。
[ServiceContract]
public interface IService1
{
[OperationContract]
[WebGet(UriTemplate = "greet/{value}", BodyStyle = WebMessageBodyStyle.Bare)]
string GetData(string value);
[OperationContract]
[WebGet(UriTemplate = "foo", BodyStyle = WebMessageBodyStyle.Bare, ResponseFormat = WebMessageFormat.Json)]
string Foo();
ResponseFormat 的选项是 WebMessageFormat.Json 和 WebMessageFormat.Xml。是否可以编写我自己的网络消息格式?我希望当客户端调用 foo() 方法时,他得到原始字符串 - 没有 json 或 xml 包装器。
【问题讨论】:
标签: c# wcf webget responseformat