使用CustomBinding的WCF服务配置HTTPS

RBr*_*g99 7 https wcf wcf-binding transport basic-authentication

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

   <endpoint address="" behaviorConfiguration="web" contract="SmsService.ISmsReceive" binding="customBinding" bindingConfiguration="RawReceiveCapable"></endpoint>
Run Code Online (Sandbox Code Playgroud)

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>
Run Code Online (Sandbox Code Playgroud)

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

谢谢

射线

Sey*_*our 12

我认为您需要删除该<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>
Run Code Online (Sandbox Code Playgroud)

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