Wednesday, March 21, 2012

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

Wednesday, March 21, 2012 Posted by Andre Broers , , , 8 comments
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
 Action: http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT
 ClientIdentity:
 ActivityId:
 FileNotFoundException: Could not load file or assembly 'Oracle.DataAccess, Version=4.112.2.0, 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.

8 comments: