title: Xml errors thrown via Ws-fed authentication
body: <p>I'm seeing the following error occur in the logs of a WIF-based reliant-party application that I work on and can't re-create the issue:</p>
  
  <pre><code>CData elements not valid at top level of an XML document. Line 1, position 3.
  Stack Trace: at   System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, XmlException exception)
  at System.Xml.XmlUTF8TextReader.Read()
  at   System.Xml.XmlBaseReader.MoveToContent()
  at Microsoft.IdentityModel.Protocols.WSFederation.WSFederationSerializer..ctor(XmlDictionaryReader reader)
  at Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.CreateSerializerForResultXml(String resultXml)
  at Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.GetXmlTokenFromMessage(SignInResponseMessage message)
  at Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.GetSecurityToken(SignInResponseMessage message)
  at Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.SignInWithResponseMessage(HttpRequest request)
  at Microsoft.IdentityModel.Web.WSFederationAuthenticationModule.OnAuthenticateRequest(Object sender, EventArgs args)
  at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) 
  </code></pre>
  
  <p>Reading into possible issues <a href="http://social.technet.microsoft.com/Forums/uk/sharepoint2010programming/thread/00bb20a1-0e7f-4c3e-a1d5-9b8b08462bab" rel="nofollow">this Technet article</a> led me to think the problem was in the wresult parameter that is POSTed back to the RP from the STS but I can't see how that is being sent back incorrectly unless it's being tampered with and that seems unlikely due to the volume of issues.</p>
  
  <p>If anyone can confirm what causes this type of error and how it may occur, it'd be much appreciated.</p>