2010-08-25 74 views
0

我正在使用ASMX Web服務並使用customBinding爲服務創建WCF客戶端。在customBinding安全部分中,我使用authenticationMode作爲「KerberosOverTransport」並使用HTTP作爲傳輸介質。請參閱下面的代碼。使用WCF進行Kerberos身份驗證customBinding

<customBinding> 
    <binding name="Service1Soap" closeTimeout="00:01:00" openTimeout="00:01:00" 
     receiveTimeout="00:10:00" sendTimeout="00:01:00"> 
     <security allowSerializedSigningTokenOnReply="true" authenticationMode="KerberosOverTransport" 
     requireDerivedKeys="false" messageProtectionOrder="SignBeforeEncryptAndEncryptSignature" 
     messageSecurityVersion="Default" requireSecurityContextCancellation="false"> 
     <secureConversationBootstrap /> 
     </security> 
     <textMessageEncoding messageVersion="Soap11" /> 
     <httpTransport authenticationScheme="Ntlm" unsafeConnectionNtlmAuthentication="false" /> 
    </binding> 
    </customBinding> 
</bindings> 
<client> 
    <endpoint address="http://localhost:1612/TestService.asmx" binding="customBinding" 
    bindingConfiguration="Service1Soap" contract="WCFProxy.Service1Soap" 
    name="Service1Soap" /> 
</client> 

當我創建一個Proxy類的實例並調用Web服務的Hello World方法時,出現以下異常。

「The'CustomBinding'。'' http://tempuri.org/'爲'Service1Soap'綁定''urn:Service1'合同配置了一個需要傳輸級別完整性和機密性的身份驗證模式,但傳輸不能提供完整性和機密性。

============================================== ============================================

at System .ServiceModel.Dispatcher.SecurityValidationBehavior.SoapOverSecureTransportRequirementsRule.ValidateSecurityBinding(SecurityBindingElement securityBindingElement,裝訂裝訂,ContractDescription合同) 在System.ServiceModel.Dispatcher.SecurityValidationBehavior.ValidateSecurityBinding(SecurityBindingElement SBE,裝訂裝訂,ContractDescription合同) 在System.ServiceModel.Dispatcher.SecurityValidationBehavior .ValidateBinding(綁定綁定,ContractDescription合同,SecurityBindingElement & securityBindingElement) 在System.ServiceModel.Dispatcher.SecurityValidationBehavior.System.ServiceModel.Description.IEndpointBehavior.Validate(ServiceEndpoint serviceEndpoint) 在System.ServiceModel.Description.ServiceEndpoint.Validate(布爾runOperationValidators,布爾isForService) 在System.ServiceModel.Channels.ServiceChannelFactory .BuildChannelFactory(ServiceEndpoint serviceEndpoint) 在System.ServiceModel.ChannelFactory.CreateFactory() 在System.ServiceModel.ChannelFactory.OnOpening() 在System.ServiceModel.Channels.CommunicationObject.Open(時間跨度超時) 在System.ServiceModel.ClientBase 1.System.ServiceModel.ICommunicationObject.Open(TimeSpan timeout) at System.ServiceModel.ClientBase 1.在D:\ Rakesh \ Test Projects \ WebServiceCustomBinding \ WCFClient \ Program.cs中的WCFClient.Program.Main(String [] args)處打開() :line 16 在System.AppDomain._nExecuteAssembly(大會組件,字串[] args) 在System.AppDomain.ExecuteAssembly(字符串assemblyFile,證據assemblySecurity,字串[] args) 在Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 在System.Threading.ThreadHelper.ThreadStart_Context(對象狀態) 在System.Threading.ExecutionContext.Run(ExecutionContext中的ExecutionContext,ContextCallback回調,對象狀態) 在System.Threading.ThreadHelper.ThreadStart()

我打不使用谷歌搜索這個例外運氣。現在已經有2天了,其中有R & D部分。請給我提供一些關於這個問題的幫助。我會很高興你的幫助!

Regards, Rakesh。

回答

0

嘗試使用basicHttpBinding的有以下安全,而不是:

<bindings> 
    <basicHttpBinding> 
    <binding name="Secured"> 
     <security mode="TransportCredentialOnly"> 
     <transport clientCredentialType="Windows" /> 
     </security> 
    </binding> 
    </basicHttpBinding> 
</bindings> 

你也可以檢查此article - 有一個有關設置客戶端部分。

+0

我已經嘗試用basicHttpBinding之前customBinding開始。我使用customBinding的原因是我的應用程序需要與需要Kerberos身份驗證才能實現SSO的Java Web服務進行互操作。 Java Web服務可能安裝在除Windows以外的任何類型的平臺上,因此在該平臺上,Windows clientCredentialType可能無法正常工作。感謝您的回覆。你能建議我一個解決方案提到的要求?對不起,以前沒有提供這些細節! – 2010-08-26 05:19:16

+0

比您需要用於測試的Java Web服務。如果您的服務的WSDL具有描述其配置的安全策略,那將是非常棒的。目前,您正嘗試使用與Java不同的ASMX來模擬服務。 – 2010-08-26 07:50:48

+0

是的,我明白。我的實際需求是在C#.NET中構建一個WCF客戶端,它將實現Kerberos身份驗證以實現SSO。這反過來會被用於認證用戶和分配Kerberos令牌的Java Windows應用程序使用。目前Java應用程序還沒有準備好,所以我試圖讓這個客戶端只與ASMX Web服務一起工作。稍後,當使用ASMX服務成功進行測試時,我會嘗試將此客戶端與Java應用程序集成。 – 2010-08-27 05:45:35

0

嘗試使用<httpsTransport requireClientCertificate="true"/>綁定元素。