WCF gives unprotected or incorrectly protected error error

I am trying to use the remote svc web service. I created a proxy class using svcutil.exe , and after that I added this class to the console application, but it gives an error:

An unsecured error or an incorrectly protected error was received from the other side. See Internal Failure Exception for DTC and Parts.

System.ServiceModel.FaultException: An error occurred while checking the security for the message

I did not create a WCF side, this is remote svc. Please, help.

 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="EloquaDataTransferService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="TransportWithMessageCredential"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="https://secure.eloqua.com/API/1.2/DataTransferService.svc" binding="basicHttpBinding" bindingConfiguration="EloquaDataTransferService" contract="DataTransferService" name="EloquaDataTransferService" /> </client> </system.serviceModel> </configuration> 

This is my app.config file. I provide the username and password in the consoleApp.cs file with obj.ServiceCredentials.UserName.UserName="xxxxxx" and .Password="xxxXx"

 <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.serviceModel> <bindings> <basicHttpBinding> <binding name="EloquaDataTransferService" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Mtom" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true"> <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" /> <security mode="TransportWithMessageCredential"> <transport clientCredentialType="None" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security> </binding> </basicHttpBinding> </bindings> <client> <endpoint address="https://secure.eloqua.com/API/1.2/DataTransferService.svc" binding="basicHttpBinding" bindingConfiguration="EloquaDataTransferService" contract="DataTransferService" name="EloquaDataTransferService" /> </client> </system.serviceModel> </configuration> 
+67
c # wcf
Sep 27 '09 at 22:02
source share
21 answers

This is a very obscure mistake that WCF services throw. The problem is that WCF cannot verify the security of the message that was sent to the service.

This is almost always due to server skew. The remote server and the client system time should be within (usually) 10 minutes of each other. If this is not the case, the security check will fail.

I would call eloqua.com and find out what they have on the server, and compare this with your server.

+130
Jan 08 2018-10-10 at
source share

Although your problem has been resolved using one of the above solutions, in the interests of others, there is another option.

You can also get this exception when invalid credentials are passed to the base endpoint (SOAP 1.1), which uses user credentials like you do. For example, if you call a service from code and do something like this:

 var service = new TestService(); service.ClientCredentials.UserName.UserName = "InvalidUser"; service.ClientCredentials.UserName.Password = "InvalidPass"; 

This differs from the WSHTTP endpoint (SOAP 1.2), which throws an AccessDeniedException when invalid credentials are skipped. I personally believe that the message contained here is a little misleading (it certainly cost me a few minutes when I first encountered this for this reason), but the main reason was clear when I consulted with WCF diagnostic trace logs.

+22
Sep 02 '11 at 8:11
source share

You obviously have a problem with the WCF security subsystem. What binding are you using? What is authentication? Encryption? Signing? Do you need to cross domain boundaries?

Looking back a bit, it shows that others experience this error if the client and server clocks are not synchronized (more than five minutes), because some security schemes rely on synchronized clocks.

+13
Sep 27 '09 at 22:35
source share

The same problem that I encountered with my client application is a WinForms C # 4.0 application

When I read the solution here, I checked the date and time of the client computer, but it was correct and the current time was showing, but still I ran into this problem.

After some workday, I found that the wrong time zone was selected, I am in India, and the time zone is in Canada, the host server is in Kuwait.

I found that the system converts time into universal time.

When I changed the time zone in the time zone of India, the problem was resolved.

+5
Aug 31 '13 at 14:15
source share

If you transfer user credentials from the client (according to the code block below), it must match the username / password on the server. otherwise, you will get this error.

FYI, in my case I use "basicHTTPAuthentication" with the security mode "TransportWithMessageCredential". And the WCF service is hosted in IIS on https.

 var service = new TestService(); service.ClientCredentials.UserName.UserName = "InvalidUser"; service.ClientCredentials.UserName.Password = "InvalidPass"; 

Hope this helps someone ... :)

+4
Mar 25 '13 at 6:20
source share

Try changing the security mode to "transport".

You have a mismatch between the security tag and the transport tag.

+3
Oct 01 '09 at 14:07
source share

What is it worth? I also had this error and found that it was caused by the connection string in web services, where web.config is configured to connect to the wrong machine.

+2
Jul 19 2018-11-11T00:
source share

In my case, when I changed the wshttpbinding protocol from https to http , it started working.

+2
May 18 '12 at 6:50
source share

In my case, I used certificates for authentication using the certificateValidationMode parameter set to "PeerTrust", and I forgot to install the client certificate in the Windows store (LocalMachine \ TrustedPeople) to make it a accepted server.

+2
Jul 28 '15 at 16:42
source share

In most cases, this exception occurs when errors occur on the server, the most common of which is incorrect authentication database configuration or authentication. In my case, there was a different clock synchronization, make sure that both clients and servers have the same settings

Click "Time on the right side" β†’ "Change time settings ..." β†’ "Internet time" β†’ Change settings ... β†’ check the box "Synchronize with the Internet time server" if it is not installed β†’ select "from the server drop-down list" times.windows.com "β†’ Update Now β†’ OK

+2
Mar 14 '17 at 9:13
source share

I also had this problem from the help desk, outdated, even with the server and client on the same computer. Running the "Update Service Reference" usually fixes this if it is a problem.

+1
Aug 24 '10 at 6:27
source share

In my case, I was getting this error on the same machine, in my test client-server application. But this problem was resolved with the help of the Update Helpdesk.

  • Tushar G. Valabalkar
+1
Feb 06 '11 at 10:30
source share

Just for the sake of sharing ... I had a rare case that made me scratch my head for a few minutes. Even at a time when the skew solution was very accurate, and I solved this problem earlier, this time it was different. I was on a new Win8.1 machine, which I remember having a problem with the time zone, and I manually adjusted the time. Well, I kept getting an error, despite the fact that the time displayed on the server and the client only had a difference in seconds. What I did was activate the "summer save" (note that I am really in the summer, but when setting the time manually) in the "setting date and time" then went to the time section on the Internet and updated ... the time in my computer kept the same, but the error disappeared.

Hope this is helpful for everyone!

+1
Aug 02 '15 at 15:44
source share

In my case, there are two problems that will throw this exception.

Please note that my environment uses Single Sign On (or STS if you want) to authenticate the user through the ASP.NET MVC site. The MVC site, in turn, calls a service call to my service endpoint, passing the media token that it requested from the STS server with the Bootstrap token earlier. The error I received is when I made a service call from the MVC site.

  • The WCF service was not configured as a relying party in my SSO (or STS, if you prefer).

  • The service configuration has not been configured properly. In particular, for the audience uris node for system.identityModel. It must exactly match the service endpoint URL.

     <system.identityModel> <identityConfiguration> <audienceUris> <add value="https://localhost/IdpExample.YService/YService.svc" /> </audienceUris> .... </identityConfiguration> </system.identityModel> 
0
Jun 13
source share

Make sure your SendTimeout fails after opening the client.

0
Jul 30 '14 at 7:19
source share

Try the following:

 catch (System.Reflection.TargetInvocationException e1) String excType excType = e1.InnerException.GetType().ToString() choose case excType case "System.ServiceModel.FaultException" System.ServiceModel.FaultException e2 e2 = e1.InnerException System.ServiceModel.Channels.MessageFault fault fault = e2.CreateMessageFault() ls_message = "Class: uo_bcfeWS, Method: registraUnilateral ~r~n" + "Exception(1): " + fault.Reason.ToString() if (fault.HasDetail) then System.Xml.XmlReader reader reader = fault.GetReaderAtDetailContents() ls_message += " " + reader.Value do while reader.Read() ls_message += reader.Value loop end if case "System.Text.DecoderFallbackException" System.Text.DecoderFallbackException e3 e3 = e1.InnerException ls_message = "Class: uo_bcfeWS, Method: registraUnilateral ~r~n" + "Exception(1): " + e3.Message case else ls_message = "Class: uo_bcfeWS, Method: registraUnilateral ~r~n" + "Exception(1): " + e1.Message end choose MessageBox ( "Error", ls_message ) //logError(ls_message) return false 
0
Dec 12 '14 at 1:37
source share

I was getting this error because BasicHttpBinding did not send a compatible messageVersion to the service that I was calling. My solution was to use custom binding as shown below

  <bindings> <customBinding> <binding name="Soap11UserNameOverTransport" openTimeout="00:01:00" receiveTimeout="00:1:00" > <security authenticationMode="UserNameOverTransport"> </security> <textMessageEncoding messageVersion="Soap11WSAddressing10" writeEncoding="utf-8" /> <httpsTransport></httpsTransport> </binding> </customBinding> </bindings> 
0
Feb 20 '15 at 2:02
source share

 <wsHttpBinding> <binding name="ISG_Binding_Configuration" bypassProxyOnLocal="true" useDefaultWebProxy="false" hostNameComparisonMode="WeakWildcard" sendTimeout="00:30:00" receiveTimeout="00:30:00" maxReceivedMessageSize="2147483647" maxBufferPoolSize="2147483647"> <readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647" /> <security mode="None"> <message establishSecurityContext="false" clientCredentialType="UserName"/> </security> </binding> </wsHttpBinding> 
0
Jul 19 '17 at 11:55
source share

I had to change SecurityMode to Message (WSHttpBinding) before it worked. those.

 _wcf = new ServiceRequestClient(new WSHttpBinding(SecurityMode.Message), new EndpointAddress(_wcfRequestServerAddress)); 
0
Dec 14 '17 at 10:47
source share

In my case, it was an IIS application pool setup.

Select application pool β†’ Advanced Settings β†’ Set Enable 32-bit Applications to True.

Then restart the application pool.

0
Aug 28 '18 at 14:12
source share

In my case, the server time was not correct. Therefore, I changed the Datetime server settings to Set time automatically, and this solved the problem.

0
Jul 22 '19 at 12:36
source share



All Articles