在IIS上通过WCF服务启用HTTPS

时间:2013-03-15 05:31:42

标签: wcf web-services ssl https web-config

在堆栈溢出中再次提出这个问题似乎很愚蠢,因为在这个主题上已经有足够的帖子......但是我可以看到每个帖子都有自己实现这个的方法..所以我的配置文件在下面指定.. 。我已经跟进了所有相关的帖子并编写了这个Web配置文件。但是经过一切努力我也得到了以下错误:

“无法找到与绑定BasicHttpBinding的端点的方案https匹配的基址。已注册的基址方案为[http]。”

这是我的Web.config文件

<?xml version="1.0"?>
<configuration>

    <system.web>
        <compilation debug="true" targetFramework="4.0" />
      <globalization requestEncoding="utf-8" uiCulture="en" culture="en-US" responseEncoding="utf-8"/>
    </system.web>
    <system.serviceModel>
        <services>
            <service name="WcfService.Service1" behaviorConfiguration="ReqServiceBehaviour">
                <endpoint address ="" binding="webHttpBinding" contract="WcfService.IService1" behaviorConfiguration="web"/>
                <endpoint address="files" behaviorConfiguration="web" binding="webHttpBinding"
                                bindingConfiguration="httpStreamingBinding" name="UploadEndpoint"
                                contract="WcfService.IService1" />
                <endpoint address="" binding="basicHttpBinding" bindingConfiguration="secureHttpBinding" contract="WcfService.IService1"/>

                <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
            </service>
        </services>

        <bindings>
            <webHttpBinding>
                <binding name="httpStreamingBinding" transferMode="Streamed" />
            </webHttpBinding>
            <basicHttpBinding>
                <binding name="secureHttpBinding">
                    <security mode="Transport">
                        <transport clientCredentialType="None"/>
                    </security>
                </binding>
            </basicHttpBinding>
        </bindings>

        <behaviors>
            <serviceBehaviors>
                <behavior name="ReqServiceBehaviour">
                    <!-- To avoid disclosing metadata information, set the values below to false before deployment -->
                    <serviceMetadata httpGetEnabled="true" />
                    <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
                    <serviceDebug includeExceptionDetailInFaults="false"/>
                </behavior>
            </serviceBehaviors>
            <endpointBehaviors>
                <behavior name="web">
                    <webHttp/>
                </behavior>

            </endpointBehaviors>

        </behaviors>

        <protocolMapping>

            <add binding="basicHttpsBinding" scheme="https" />
        </protocolMapping>
        <serviceHostingEnvironment  multipleSiteBindingsEnabled="true" />
    </system.serviceModel>
    <system.webServer>
        <modules runAllManagedModulesForAllRequests="true"/>
        <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
        <directoryBrowse enabled="true"/>
    </system.webServer>

</configuration>

1 个答案:

答案 0 :(得分:0)

可能你可以试试

要使用https,您需要设置httpsGetEnabled =“true”而不是httpGetEnabled =“true”