Tag: webget

WebGet的WCF ResponseFormat

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包装器。