| Message Security Exception/ Sporadic Failure in WCF calls. | 
If you have load balanced  WCF service over https with Http binding, you may encounter Message Security  exception. Here is the exception details.
Type  : System.ServiceModel.Security.MessageSecurityException, System.ServiceModel,  Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
Message  : An unsecured or incorrectly secured fault was received from the other party.  See the inner FaultException for the fault code and detail.
Cause: In WCF Load  balanced   environment the security context is maintained in a separate WCF  specific session ( note not a ASP.NET sessions); where when load balanced  switches between sever the context is lost. To avoid it we are forcing the  application to send the security context in every message call to WC. To do that  follow below configuration change in both client and in WCF  service.
Configuration change in  Client and WCF Service 
<wsHttpBinding>
<binding name="Transport_UserName">
<security mode="TransportWithMessageCredential">
<message clientCredentialType="UserName"
negotiateServiceCredential="false"
establishSecurityContext="false"/>
</security>
</binding>
</wsHttpBinding>
Reference  Article:
http://msdn.microsoft.com/en-us/library/ms730128.aspx      

No comments:
Post a Comment