【发布时间】:2015-07-28 11:32:18
【问题描述】:
这是一个以 JSON 格式发送响应的 WCF 方法。
[OperationContract(Name = "Employee")]
[WebInvoke(Method = "GET", BodyStyle = WebMessageBodyStyle.WrappedResponse, ResponseFormat = WebMessageFormat.Json, RequestFormat = WebMessageFormat.Json, UriTemplate = "person/{name}")]
Person GetPersonData(string name);
这是我得到的格式:
{"EmployeeResult":{"Age":31,"Name":"testuser"}}
我需要类似下面的东西:
{"Employee":{"Age":31,"Name":"testuser"}}
我试图改变
BodyStyle = WebMessageBodyStyle.Bare
但低于格式:
{"Age":31,"Name":"testuser"}
还有什么我需要改变的吗?我正在开发 .net 框架 4.5
谢谢
【问题讨论】: