2013-08-26 18 views
1

我有一個WCF服務,我想使用消息簽名,但僅限於某些調用 - 其他應該不被簽名。我無法弄清楚如何設置它來支持兩者。在使用傳輸安全性時爲多個消息ProtectionLevels配置服務

郵件簽名使用非Windows用戶名和密碼,通過服務端的usernamepasswordvalidator進行驗證。簽名和未簽名的消息都應使用傳輸安全性。

這裏是我的界面的例子:

[ServiceContract(ProtectionLevel=ProtectionLevel.None)] 
public interface ISecTest 
{ 
    [OperationContract(ProtectionLevel = ProtectionLevel.Sign)] 
    string GetData(string value); 

    [OperationContract(ProtectionLevel = ProtectionLevel.None)] 
    string GetStuff(string stuff); 

} 

我遇到的問題是,簽約似乎是對服務的綁定配置完全根據,而不是在接口上定義的ProtectionLevels 。

如果我用下面的綁定,通話需要的用戶名憑據,而不管的ProtectionLevel屬性:

<wsHttpBinding> 
    <binding name="secureWSHttpBindingConfig">   
     <security mode="TransportWithMessageCredential"> 
     <message clientCredentialType="UserName" /> 
     <transport clientCredentialType="None" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 

如果我省略了消息的安全性和使用下面的綁定,然後既不呼叫需要憑據:

<wsHttpBinding> 
    <binding name="tolerantWSHttpBindingConfig"> 
     <security mode="Transport">   
     <transport clientCredentialType="None" /> 
     </security> 
    </binding> 
    </wsHttpBinding> 

這是一個使用傳輸安全除messa之外的複雜ge安全? 有關如何在單個服務中完成此任務的任何建議(如果甚至可能的話)?

謝謝!

+0

出於好奇,爲什麼要降級保護級別? –

+0

我寧願不要,但我實際上是在混合前後登錄調用的舊服務的約束下工作的。 – Landstander

回答

0

當您使用傳輸安全性時,不能混用您的保護級別。如果這對你很重要,你將不得不使用消息安全。

+0

我很害怕這個...謝謝你清理那個,但是。 – Landstander

相關問題