Wednesday, March 21, 2012

"An error occurred when verifying security for the message." error inWCF Service

Wednesday, March 21, 2012 Posted by Unknown , , ,
When running a WCF service in security mode = "TransportWithMessageCredential" mode after deploying to a server I got the the FaultException: "An error occurred when verifying security for the message.".

Not a very clear error message. To get a clear message you can add the following to the web.config in the <serviceBehaviors> section for each <behavior>:
<serviceSecurityAudit auditLogLocation="Application" serviceAuthorizationAuditLevel="Failure" messageAuthenticationAuditLevel="Failure" suppressAuditFailure="true" />

Now I get a clear message in the Application EventLog:
Message authentication failed.
 Service: https://xxxxxxxxxxxxxxx.svc
 FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=, Culture=neutral, PublicKeyToken=89b483f429c47342' or one of its dependencies. The system cannot find the file specified.

Always the Oracle DLL's... My next blog post will show the solution to this problem.

Remember to remove this line from the web.config on production systems, because it implies a performance impact.