将HTTP和HTTPS绑定添加到WCF Web服务

时间:2010-08-23 12:07:51

标签: wcf configuration

我有一个WCF Werbservice,我希望通过HTTP和HTTPS与他联系。

这是我的实际尝试。但我不能再使用http而不是使用https来联系服务。 :(请帮忙

<system.serviceModel>
  <bindings>
   <basicHttpBinding>
    <binding name="DefaultBinding" closeTimeout="10:01:00" openTimeout="10:01:00" receiveTimeout="10:10:00" sendTimeout="10:01:00"
        transferMode="Streamed"
        maxBufferSize="104857600" maxBufferPoolSize="524288000" maxReceivedMessageSize="104857600">
     <readerQuotas
        maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" maxBytesPerRead="2147483647"
        maxNameTableCharCount="2147483647" />
     <security mode="None">
     </security>
    </binding>
    <binding name="SSLBinding">
     <security mode="TransportWithMessageCredential">
      <transport clientCredentialType="None"/>
     </security>
    </binding>
   </basicHttpBinding>
  </bindings>
  <services>
   <service behaviorConfiguration="DnsService.DNSSerivceBehavior" name="DnsService.DNSSerivce">
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="DefaultBinding"  contract="DnsService.IDNSService">
     <identity>
      <dns value="localhost"/>
     </identity>
    </endpoint>
    <endpoint address="" binding="basicHttpBinding" bindingConfiguration="SSLBinding"  contract="DnsService.IDNSService">
     <identity>
      <dns value="localhost"/>
     </identity>
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange"/>
   </service>
  </services>
  <behaviors>
   <serviceBehaviors>
    <behavior name="DnsService.DNSSerivceBehavior">
     <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
     <serviceMetadata httpGetEnabled="true"/>
     <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="true"/>
    </behavior>
   </serviceBehaviors>
  </behaviors>
 </system.serviceModel>

1 个答案:

答案 0 :(得分:1)

首先,您有两个带有空白地址的端点和两个带有mex地址的端点,但这些端点没有相同的绑定。您必须为这些端点定义不同的地址。对于安全绑定,除非要对用户进行身份验证,否则仅指定传输模式。对于服务元数据,使用包含这两个属性的单个元素替换两个serviceMetadata。

为什么要使用10小时超时?

相关问题