如何使用具有以下绑定配置的HTTPS服务?

时间:2013-06-19 10:31:10

标签: wcf https web-config basichttpbinding

以下是在WCF的web.config中配置serviceModel的方法:

<system.serviceModel>
    <bindings>
      <basicHttpBinding>
        <binding name="basicHttpWithSecure">
          <security mode="TransportCredentialOnly">
            <transport clientCredentialType="Basic"></transport>
          </security>
        </binding>
      </basicHttpBinding>

    </bindings>
    <services>
      <service name="CMA.Customers">
        <endpoint name="basic" binding="basicHttpBinding" contract="CMA.Customers" bindingConfiguration="basicHttpWithSecure"></endpoint>
      </service>      
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpsGetEnabled="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>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>

此服务部署在IIS上,我可以使用网址访问它 - https://www.companyname.co.uk/sitename/wcfservicename/service.svc 对于此WCF,身份验证在IIS中设置为“匿名”和“基本”。

现在我在同一个站点上部署了一个MVC应用程序,我想指出MVC站点使用这个WCF。如何在我的MVC站点的web.config中配置它?

或者您认为WCF配置中需要进行哪些更改才能实现?

1 个答案:

答案 0 :(得分:2)

更改您的安全模式:

<security mode="TransportCredentialOnly">

<security mode="Transport">

因为TransportCredentialOnly用于基于http的客户端身份验证。