从浏览器调用 JSON Rest 服务



想要在我的 REST JSON WCF 服务上启用 https 并在 IE 浏览器中对其进行测试。 WSDL 正在加载,没有问题 (https://localhost/myservice/Imyservice.svc?WSDL(。 但是我试图调用一个操作(https://localhost/myservice/Imyservice.svc/Getdata(,我得到了 请求错误服务器在处理请求时遇到错误。. 下面是我的网络配置。谁能帮我解决这个问题

<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"

如果问题仍然存在,请随时告诉我。

最新更新