2013-10-07 81 views
4

我需要一個WCF服務的自定義綁定,以允許我將原始內容傳遞給WCFRest服務。效果很好,但我無法接受傳輸級別的安全性。我想在其他地方使用https和basicauthentication。端點看起來是這樣的:WCF服務配置HTTPS與CustomBinding

<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。

感謝

回答

6

我認爲你需要刪除<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