我有一个从客户端 JavaScript 调用的 WCF 服务。调用失败并出现 Service is null JavaScript 错误。 WebDevelopment 帮助程序跟踪显示加载 jsdebug 支持文件的调用会导致 404(文件未找到)错误。
重新启动 IIS 或清除临时 ASP.Net 文件或在 web.config 中的编译标记上设置 batch="false" 无法解决问题
从浏览器
https://Myserver/MyApp/Services/MyService.svc https://Myserver/MyApp/Services/MyService.svc显示服务元数据
however
https://Myserver/MyApp/Services/MyService.svc/jsdebug https://Myserver/MyApp/Services/MyService.svc/jsdebug结果是 404。
问题似乎与 https 协议有关。使用 http /jsdebug 下载支持的 JS 文件。
有任何想法吗?
TIA
弄清楚了!
这是 web.config 中的服务配置部分
查看端点上的绑定配置属性。值“webBinding”指向绑定中的绑定名称=“webBinding”标记,这就是告诉服务使用 HTTPS 传输级别安全性的内容。在我的例子中,属性值为空,导致通过 HTTPS 对 /js 或 /jsdebug 文件的 Web 服务请求失败并引发 404 错误。
<services>
<service name="MyService">
<endpoint address="" behaviorConfiguration="MyServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBinding" contract="Services.MyService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="webBinding">
<security mode="Transport">
</security>
</binding>
</webHttpBinding>
</bindings>
请注意,如果通过 http 而不是 https 访问服务(在没有证书的本地计算机上进行测试时),则 bindingConfiguration 属性应为空 ("")
希望这对某人有帮助。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)