Subject: Multiple Root Element during ArtifactResponse.Send()
Date: 2018-01-03 12:46:57
From: jaydevsolanki047
Source: multiple-root-element-artifactresponse-send
----------------------------------------------------------------------

I have implemented the changes related to SP in my client application and everything is working as usual but when I call 

      case SamlBindingUri.HttpArtifact:
                    // Receive the artifact.
                    Saml2ArtifactType0004 httpArtifact = Saml2ArtifactType0004.CreateFromHttpArtifactQueryString(page.Request);

                    // Create an artifact resolve request.
                    ArtifactResolve artifactResolve = new ArtifactResolve();
                    artifactResolve.Issuer = new Issuer(Util.GetAbsoluteUrl(page, "~/"));
                    artifactResolve.Artifact = new Artifact(httpArtifact.ToString());

                    // Look up for the appropriate artifact SP url
                    string referer = page.Request.UrlReferrer.AbsoluteUri;
                    int i;
                    for (i = 0; i < Services.AllowedServiceUrls.Length; i  )
                    {
                        string url = Services.AllowedServiceUrls[i];

                        if (referer.StartsWith(url))
                            break;
                    }

                    if (i == Services.AllowedServiceUrls.Length)
                        throw new Exception("Your SP is not allowed");

                    // Send the artifact resolve request and receive the artifact response.
                    string artifactServiceProviderUrl = Services.ArtifactServiceProviderUrls[i];

                    ArtifactResponse artifactResponse = ArtifactResponse.SendSamlMessageReceiveAftifactResponse(artifactServiceProviderUrl, artifactResolve);

                    // Extract the authentication request from the artifact response.
                    authnRequest = new AuthnRequest(artifactResponse.Message);
                    relayState = httpArtifact.RelayState;
                    break;

from **Util.cs** in IDP project, It redirects it to the page SamlArtifactResolve.aspx.

When i debug the line artifactResponse.Send(Response); from (**SamlArtifactResolve.aspx**) 

      ArtifactResolve artifactResolve = ArtifactResolve.Create(Request);

                // Get the artifact.
                Saml2ArtifactType0004 httpArtifact = new Saml2ArtifactType0004(artifactResolve.Artifact.ArtifactValue);

                // Remove the artifact state from the cache.
                XmlElement artifactXml = (XmlElement)SamlSettings.CacheProvider.Remove(httpArtifact.ToString());
                if (artifactXml == null)
                    return;

                // Create an artifact response containing the cached SAML message.
                ArtifactResponse artifactResponse = new ArtifactResponse();
                artifactResponse.Issuer = new Issuer(Util.GetAbsoluteUrl(this, "~/"));
                artifactResponse.Message = artifactXml;

                // Send the artifact response.
                artifactResponse.Send(Response);

I get exception of There are Multiple root elements. Below is a stacktrace.

       
   at ComponentPro.Saml2.ArtifactResponse.SendSamlMessageReceiveAftifactResponse(String destinationUrl, SignableSamlObject samlMessage)
   at SamlSPInitiated.IdentityProvider.Util.ReceiveAuthnRequest(Page page, AuthnRequest& authnRequest, String& relayState) in E:\Test\Web\Source\Application\Test.IdentityProvider\Util.cs:line 63


[Note : I have checked the XML format of the request and there is a single root element.]

----------------------------------------------------------------------

Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand
If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor
who sold you the license and ask for your money back.

Back to ComponentPro Q&A Forum Index