【发布时间】:2014-06-26 23:39:32
【问题描述】:
我想创建 WCF Restful 服务,它将复杂类型作为 Json 格式的参数并返回 Json。我阅读了很多文章并检查了网络上的许多示例。一些文章建议在 Endpoint 行为中添加标签并装饰 Service 方法,如下所示,
[WebInvoke(UriTemplate = "/PlaceOrder",
RequestFormat= WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, Method = "POST")]
在这种情况下,WCF 返回"Endpoints using 'UriTemplate' cannot be used with 'System.ServiceModel.Description.WebScriptEnablingBehavior'." 错误消息。
另一种建议的方法(如本文中的http://dotnetmentors.com/wcf/wcf-rest-service-to-get-or-post-json-data-and-retrieve-json-data-with-datacontract.aspx)是将“”标签添加到端点行为而不是 .但是在这种情况下 IIS 返回 ("The remote server returned an error: (400) Bad Request.") 错误消息。
您能否帮我创建一个以 json 格式接受复杂类型参数并返回 json 的 Restful 服务。
【问题讨论】:
标签: c# json web-services wcf rest