rest - 从浏览器调用 JSON Rest 服务
问题描述
想在我的 REST JSON WCF 服务上启用 https 并在 IE 浏览器中对其进行测试。WSDL 加载没有问题(https://localhost/myservice/Imyservice.svc?WSDL)。但我试图调用一个操作(https://localhost/myservice/Imyservice.svc/Getdata),我收到 请求错误服务器在处理请求时遇到错误。. 下面是我的 web.config。谁能帮我这个
<webHttpBinding>
<binding name="SecureBasicRest" allowCookies="true" >
<security mode="Transport" />
<readerQuotas maxDepth="32"/>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="svcBehavior">
<serviceMetadata httpsGetEnabled="true" httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="svcEndpoint">
<webHttp helpEnabled="true"/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="myservice.Imyservice" behaviorConfiguration="svcBehavior">
<endpoint binding="webHttpBinding" bindingConfiguration="SecureBasicRest"
behaviorConfiguration="svcEndpoint" name="webHttp"
contract="myservice.Imyservice" />
</service>
</services>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
解决方案
根本原因是服务端点的定义有问题。
<service name="myservice.Imyservice" behaviorConfiguration="svcBehavior">
<endpoint binding="webHttpBinding" bindingConfiguration="SecureBasicRest"
behaviorConfiguration="svcEndpoint" name="webHttp"
contract="myservice.Imyservice" />
</service>
您的想法是正确的,我们应该添加一个具有传输安全模式的服务端点。但是,服务名称应该是服务实现类的完全限定名称,而不是服务接口。
<service name="myservice.myservice"
如果问题仍然存在,请随时告诉我。
推荐阅读
- c++ - 如何将 vcpkg boost 与 MinGW 链接
- javascript - 新实现的条件语句抛出未知控制台错误并破坏 JS 蛇游戏
- ios - 如何从 Apple 键盘听写中删除 TextView 中的蓝色虚线建议下划线?
- java - 在 Wildfly 14 中获取 JTA UserTransaction
- python - 为什么该对象没有已在另一个模块中定义的属性?
- python - PyTorch 何时自动转换 Tensor dtype?
- protractor - protractorJS chai - 如何使用 getText() 断言数组中元素的文本包含字符串?
- load-testing - Liquibase:在这种情况下如何将我的数据库恢复到以前的状态
- java - 等待两个异步 firebase ml 视觉方法结果以在第三种方法中使用它们的最佳方法
- c++ - 使用 boost::geometry::within 编译错误