使用CustomBinding的WCF服务配置HTTPS

时间:2013-10-07 18:56:43

标签: wcf https wcf-binding http-basic-authentication transport

我需要在WCF服务上进行自定义绑定,以允许我将原始内容传递给WCFRest服务。效果很好,但我不能让它接受传输级别的安全性。我想在其他地方使用https和basicauthentication。端点看起来像这样:

   <endpoint address="" behaviorConfiguration="web" contract="SmsService.ISmsReceive" binding="customBinding" bindingConfiguration="RawReceiveCapable"></endpoint>

customBinding看起来像这样:

  <customBinding>
    <binding name="RawReceiveCapable">
      <security mode="Transport">
        <transport clientCredentialType="Basic"/>
      </security>
      <webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      <httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
    </binding>
  </customBinding>

但是系统抱怨安全节点中不允许使用mode属性。没有安全节点,一切都很好,但它不是https。

由于

1 个答案:

答案 0 :(得分:11)

我认为您需要删除<security>元素,然后将httpTransport元素更改为httpsTransport,如以下示例所示:

<system.serviceModel>
    <bindings>
        <customBinding>
            <binding name="RawReceiveCapable">
              <webMessageEncoding webContentTypeMapperType="SmsService.RawContentTypeMapper, SmsService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
              <httpsTransport authenticationScheme="Basic"  manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" />
            </binding>
        </customBinding>
    </bindings>

以下链接可能会有所帮助: http://msdn.microsoft.com/en-us/library/ms731818.aspx

相关问题