WCF cung cấp hai tùy chọn cho thuộc tính ResponseFormat trong chú thích WebGet trong ServiceContract.WCF ResponseFormat Đối với WebGet
[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();
Các tùy chọn cho ResponseFormat là WebMessageFormat.Json và WebMessageFormat.Xml. Có thể viết định dạng tin nhắn web của riêng tôi không? Tôi muốn rằng khi khách hàng gọi foo() phương pháp ông được chuỗi thô - không có json hoặc xml wrappers.
Nice. Nó hoạt động - vẫn có vẻ như có một WebMessageFormat.Raw. Cảm ơn. –