WCF服务通过https运行

时间:2013-08-15 13:28:26

标签: wcf iis https

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

我的要求很简单,我需要在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 ”,然后我开始收到错误:< / p>

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

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

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

专家友好地帮助我。任何指针都将受到高度赞赏。

此致

阿努拉格

0 个答案:

没有答案
相关问题