0

可能这个问题以前被问过很多次,但由于我无法解决我的问题,因此发布了这个问题。

那么我的要求很简单,我需要在 https 下运行我的服务。我创建了一个普通的 WCF 服务,它返回当前日期和时间以及传递的字符串。

当我通过浏览器在 http 下查看 Service.svc 文件时,它工作得很好。

我对我的 web.config 进行了一些更改,以使该服务与 https 兼容,并在我的本地 IIS 中创建了一个证书。

下面是我的 web.config 文件:

<system.serviceModel>
<services>
  <service name="Service" behaviorConfiguration="ServiceBehavior">
    <!-- Service Endpoints -->
    <endpoint address="" binding="wsHttpBinding" bindingConfiguration="customHttp" contract="IService">

      <identity>
        <dns value="localhost"/>
      </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
  </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="ServiceBehavior">
     <serviceMetadata httpsGetEnabled="true"/>
      <serviceDebug includeExceptionDetailInFaults="false"/>
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <wsHttpBinding>
    <binding name="customHttp">
      <security mode="Transport">
        <transport clientCredentialType="None"/>
      </security>
    </binding>
  </wsHttpBinding>
</bindings>

我创建了一个新的 wsHttpBinding 绑定,安全模式为传输,并将绑定配置附加到首选端点。

当我尝试在浏览器中浏览 service.svc 文件时,它显示:

找不到与具有绑定 WSHttpBinding 的端点的方案 https 匹配的基地址。注册的基地址方案是 [http]。

我将端点地址部分中的服务 URL 指定为“ http://[localhost:54110]/samplewcf/Service.svc ”,然后我开始收到错误消息:

找不到与绑定 MetadataExchangeHttpsBinding 的终结点的方案 https 匹配的基地址。注册的基地址方案是 [http]。

我试图将 wsHttpBinding 更改为 basicHttpBinding 和 webHttpBinding,但它不起作用。我收到上述错误。

由于我在 IIS 中使用服务器证书手动创建了证书,因此我可以通过 https 浏览 localhost,但我的服务不在 https 下运行。我在 Stack Overflow 和许多博客中浏览了许多帖子,但找不到解决方案。

专家请帮助我。任何指针将不胜感激。

问候

阿努拉格

4

0 回答 0