2016-01-13 61 views
0

我有一個WCF REST服務必須接受來自客戶端的原始輸入流。爲了接收原始流,我在我的web.config文件中使用了自定義綁定。如果我將它設置爲通過標準HTTP進行連接,該服務可以正常工作。但是,我很難讓它通過HTTPS工作。帶定製綁定的WCF REST服務的SSL配置

手動尋址不支持消息級安全性。配置綁定('CustomBinding','http://tempuri.org/')以使用傳輸安全性或不執行手動尋址。

下面是我使用HTTP配置:

<service behaviorConfiguration="LocalBehavior" name="RestService.CreditService"> 
    <endpoint address="" behaviorConfiguration="web" binding="customBinding" bindingConfiguration="RawReceiveCapable" contract="RestService.ICreditService" /> 
</service> 

<behavior name="LocalBehavior"> 
    <serviceMetadata httpGetEnabled="true" /> 
    <serviceDebug includeExceptionDetailInFaults="true" /> 
</behavior> 

<endpointBehaviors> 
    <behavior name="web"> 
     <webHttp /> 
    </behavior> 
</endpointBehaviors> 

<binding name="RawReceiveCapable"> 
    <webMessageEncoding webContentTypeMapperType="RestService.Data.RawContentTypeMapper, RestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
    <httpTransport manualAddressing="true" maxReceivedMessageSize="524288000" 
      transferMode="Streamed" /> 
</binding> 

這裏是我使用HTTPS的配置:

<service behaviorConfiguration="SecureBehavior" name="RestService.CreditService"> 
     <endpoint address="basic" behaviorConfiguration="web" binding="customBinding" bindingConfiguration="RawReceiveCapable" name="httpsEndpoint" contract="RestService.ICreditService" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="http://sitcreditserviceszalecorp.cloudapp.net:3389/CreditService.svc" /> 
      <add baseAddress="https://sitcreditserviceszalecorp.cloudapp.net:443/CreditService.svc" /> 
      </baseAddresses> 
     </host> 
</service> 

<behavior name="SecureBehavior"> 
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="true" /> 
      <serviceDebug httpHelpPageEnabled="false" httpsHelpPageEnabled="true" includeExceptionDetailInFaults="true" /> 
</behavior> 

<binding name="RawReceiveCapable"> 
      <webMessageEncoding webContentTypeMapperType="RestService.Data.RawContentTypeMapper, RestService, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> 
      <security authenticationMode="CertificateOverTransport" 
        requireSecurityContextCancellation ="true"> 
      </security> 
      <httpsTransport manualAddressing="true" maxReceivedMessageSize="524288000" transferMode="Streamed" authenticationScheme="Anonymous" requireClientCertificate="false" /> 
</binding> 

任何人都可以指出我」米做錯了嗎?謝謝。

回答

-1

我遇到同樣的問題,直到我遇到一篇文章,建議刪除安全元素。這對我有效。