string msg = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope//">";
msg += "<SOAP-ENV:Body>";
msg += " <samlp:ArtifactResponse xmlns:samlp=\"urn:oasis:names:tc:SAML:2.0:protocol\"";
msg += " xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\" ID=\"8292855779514728a303b68636649b90\"";
msg += " IssueInstant=\"2010-07-13 02:42:58\" InResponseTo=\"faa4fee5be6b4726ad559c450171fdca\"";
msg += " Version=\"2.0\">";
msg += " <samlp:Status>";
msg += " <samlp:StatusCode Value=\"urn:oasis:names:tc:SAML:2.0:status:Success\" />";
msg += " </samlp:Status>";
msg += " <samlp:Response xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"";
msg += " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance/" ID=\"fc8ef5d6487149c4a9195f6a55628dba\"";
msg += " IssueInstant=\"2010-07-13 02:44:34\" InResponseTo=\"0f37aa7a104a41ab8804f69f414bd06a\"";
msg += " Version=\"2.0\">";
msg += " <saml:Issuer>https://ac.chinamobile.com/</saml:Issuer>";
msg += " <samlp:Status>";
msg += " <samlp:StatusCode Value=\"urn:oasis:names:tc:SAML:2.0:status:Success\" />";
msg += " </samlp:Status>";
msg += " <saml:Assertion ID=\"8b208dd8ee8b4570b44ae201e0f1a75f\"";
msg += " Version=\"2.0\" IssueInstant=\"2010-07-13 02:44:34\">";
msg += " <saml:Issuer>https://ac.chinamobile.com/</saml:Issuer>";
msg += " <saml:Subject>";
msg += " <saml:NameID Format=\"urn:oasis:names:tc:SAML:2.0:nameid-format:transient\">13612345678</saml:NameID>";
msg += " </saml:Subject>";
msg += " <saml:Conditions NotBefore=\"2010-07-13 02:44:34\"";
msg += " NotOnOrAfter=\"2010-07-13 04:14:34\" />";
msg += " <saml:AttributeStatement>";
msg += " <saml:Attribute";
msg += " NameFormat=\"urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified\"";
msg += " Name=\"userinfo\">";
msg += " <saml:AttributeValue xsi:type=\"xs:string\">MSISDN</saml:AttributeValue>";
msg += " <saml:AttributeValue xsi:type=\"xs:string\">Province</saml:AttributeValue>";
msg += " <saml:AttributeValue xsi:type=\"xs:string\">name</saml:AttributeValue>";
msg += " <saml:AttributeValue xsi:type=\"xs:string\">brand</saml:AttributeValue>";
msg += " <saml:AttributeValue xsi:type=\"xs:string\">status</saml:AttributeValue>";
msg += " <saml:AttributeValue xsi:type=\"xs:string\"> Date </saml:AttributeValue>";
msg += " <saml:AttributeValue xsi:type=\"xs:string\">NickName</saml:AttributeValue>";
msg += " <saml:AttributeValue xsi:type=\"xs:string\">139MailStatus</saml:AttributeValue>";
msg += " <saml:AttributeValue xsi:type=\"xs:string\">FetionStatus</saml:AttributeValue>";
msg += " </saml:Attribute>";
msg += " </saml:AttributeStatement>";
msg += " </saml:Assertion>";
msg += " </samlp:Response>";
msg += " </samlp:ArtifactResponse>";
msg += " </SOAP-ENV:Body>";
msg += "</SOAP-ENV:Envelope>";
************************
public void ParseSAML(string strSAML)
{
XmlDocument xDoc = new XmlDocument();
xDoc.LoadXml(strSAML);
XmlNamespaceManager xMan = new XmlNamespaceManager(xDoc.NameTable);
xMan.AddNamespace("SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/");
xMan.AddNamespace("samlp", "urn:oasis:names:tc:SAML:2.0:protocol");
xMan.AddNamespace("saml", "urn:oasis:names:tc:SAML:2.0:assertion");
XmlNode xNode = null;
xNode = xDoc.SelectSingleNode("SOAP-ENV:Envelope/SOAP-ENV:Body/samlp:ArtifactResponse/samlp:Response/samlp:Status/samlp:StatusCode/@Value", xMan);
if (xNode != null)
{
string statusCode = xNode.Value;
Response.Write("statusCode=" + statusCode + "<br />");
Regex reg = new Regex(@"urn:oasis:names:tc:SAML:2.0:status:\w+");
statusCode = reg.Match(statusCode).Value.Replace("urn:oasis:names:tc:SAML:2.0:status:", "");
Response.Write("statusCode=" + statusCode + "<br />");
}
xNode = xDoc.SelectSingleNode("SOAP-ENV:Envelope/SOAP-ENV:Body/samlp:ArtifactResponse/samlp:Response/saml:Assertion/saml:Subject/saml:NameID", xMan);
if (xNode != null)
{
string NameID = xNode.InnerText;
Response.Write("NameID=" + NameID + "<br />");
}
XmlNodeList nl = xDoc.SelectSingleNode("SOAP-ENV:Envelope/SOAP-ENV:Body/samlp:ArtifactResponse/samlp:Response/saml:Assertion/saml:AttributeStatement/saml:Attribute[@Name = 'userinfo']", xMan).ChildNodes;
foreach (XmlNode xn in nl)
{
if (xn != null)
{
string firstName = xn.InnerText;
Response.Write("firstName=" + firstName + "<br />");
}
}
}
********************************