ASP源码.NET源码PHP源码JSP源码JAVA源码DELPHI源码PB源码VC源码VB源码Android源码
当前位置:首页 >> 低调看直播体育app软件下载 >> .NETjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播 >> androidsyncservice WCF Data Service with OData v3 使用jsonp 跨域访问

androidsyncservice WCF Data Service with OData v3 使用jsonp 跨域访问

来源:网络整理     时间:2016-06-14     关键词:androidsyncservice

本篇文章主要介绍了"androidsyncservice WCF Data Service with OData v3 使用jsonp 跨域访问",主要涉及到androidsyncservice方面的内容,对于.NETjrs看球网直播吧_低调看直播体育app软件下载_低调看体育直播感兴趣的同学可以参考一下: WCF Data Service with OData 是一个优秀的Restful Web Service在ASP.NET下的实现,但是在使用中,我遇到了一个...

WCF Data Service with OData  是一个优秀的Restful Web Service在ASP.NET下的实现,但是在使用中,我遇到了一个问题,即当我单独部署WDS服务的时候,Ajax访问就需要跨域。

在一般的WCF服务中,我们可以用JSONP解决。所以我发起了下面这个请求:

 WCF Data Service with OData v3 使用jsonp 跨域访问

你可以看到响应的ContentType是application/json,所以浏览器抛出了一个异常

 WCF Data Service with OData v3 使用jsonp 跨域访问

Refused to execute script from 'http://***.svc/Companies?$filter=Type%20eq%201&$for…on&js because its MIME type ('application/json') is not executable, and strict MIME type checking is enabled.

加粗的部分告诉我们,application/json类型不可执行。JSONP要求回传类型为application/json-p或者text/json-p

但是WDS服务的响应类型只支持Atom、XML和JSON,并不支持JSONP。

最终,在MSDN上看到了一篇Blog,其中有一段:

There are two things needed to support JSONP properly:

  • The ability to control the response format. Data Services uses standard HTTP content type negotiation to select what representation of a given resource should be sent to the client (e.g. JSON, Atom). That requires that the caller can set the Accept request header, which is not possible when doing the JSONP trick (which basically just uses

androidsyncservice相关图片

androidsyncservice相关文章