开发者

What is reponse.d when returning data from a WCF Service with ContentType of "application/json"?

I have a WCF service that has webHttpBinding and has enableWebScript turned on in it's endpoint behavior configuration.

The response from the service looks something like this

HTTP/1.1 200 OK Date: Fri, 23 Oct 2009 20:09:02 GMT Server: Microsoft-IIS/6.0 X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: application/json; charset=utf-8 Content-Length: 25

{"d":{"__type":"SOMETYPE", ... }}

Its using HTTP 1.1 and so there are the standard headers. The contentType is set to be applciation/json which also makes sense. In开发者_JAVA百科 the message body (the JSON part), everything is enclosed in an envelope titled "d".

What is that? Who defines that protocol? Is it something specific to WCF?

I couldn't find that defined in any of the protocols involved or the definition of the "application/json" contentType.

Thanks


That is ASP.NET AJAX specific and is caused by applying the WebScriptEnablingBehavior (enableWebScript in config) to your endpoint. The wrapper is required on both input and output and there are also special behaviors added around exception handling.

If you want "pure" JSON, you should remove the WebScriptEnablingBehavior and just use WebHttpBehavior (webHttp in config). Then just make sure you explicitly set the Request/ResponseFormat properties on your WebGet/InvokeAttributes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜