25 Kasım 2015 Çarşamba

WCF SecurityNegotiationException Hatası


"Unhandled Exception: System.ServiceModel.Security.SecurityNegotiationException: Secure channel cannot be opened because security negotiation with the remote endpoint has failed. This may be due to absent or incorrectly specified EndpointIdentity in the EndpointAddress used to create the channel. Please verify the EndpointIdentity specified or implied by the EndpointAddress correctly identifies the remote endpoint. ---> System.ServiceModel.FaultException: The message with Action 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None)."

Hatasını aldığınızda Enpoint adresinde bazı security, mesaj ve Transport ayarlarından dolayı hata almaktasınız.Bu servisin yapısına göre değişkenlik gösterebilir.

Bir windows web servis için yaptığımız configurasyon örneği aşağıdaki gibidir

System.ServiceModel.WSHttpBinding binding = new System.ServiceModel.WSHttpBinding();



binding.MaxReceivedMessageSize = 2147483647;
binding.CloseTimeout = TimeSpan.MaxValue;
binding.OpenTimeout = TimeSpan.MaxValue;
binding.ReceiveTimeout = TimeSpan.MaxValue;
binding.SendTimeout = TimeSpan.MaxValue;

WSHttpSecurity _wsHttpSecurity = new WSHttpSecurity();
_wsHttpSecurity.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
_wsHttpSecurity.Transport.ProxyCredentialType = HttpProxyCredentialType.None;
_wsHttpSecurity.Transport.Realm = "";

_wsHttpSecurity.Message.ClientCredentialType = MessageCredentialType.Windows;
_wsHttpSecurity.Message.NegotiateServiceCredential = true;
_wsHttpSecurity.Message.EstablishSecurityContext = true;

_wsHttpSecurity.Mode = SecurityMode.None;



binding.Security = _wsHttpSecurity;
.
EndpointAddress endpointAddress = new EndpointAddress("***/Retrieval.svc"); //Live


RetrievallWS.RetrievalClient retrievallWS = new RetrievallWS.RetrievalClient(binding, endpointAddress);


          

Hiç yorum yok:

Yorum Gönder