我是使用IIS作为服务的宿主,因此需要在web.config中增加如下配置节:
<bindings>
<webHttpBinding>
<binding name="webBinding" crossDomainScriptAccessEnabled="true" />
</webHttpBinding>
</bindings>
然后在终点上应用绑定配置:
<endpoint address="" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Jintu.Report.Interface.IReportService" behaviorConfiguration="webHttp"/>
除配置文件中增加配置信息外,还需要在接口实现类(服务)上增加如下属性:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[JavascriptCallbackBehavior(UrlParameterName ="jsoncallback")]