CorePHP - SAMLSignOn failed: Failed to convert the base-64 encoded string into XML

I have setup Identity Provider for SAML assertion using corePHP. I am using curl to send assertion request to Service Provider.

My identity provider is on core php using curl.

Service Provider is made using componentspace saml2.0 in asp.net

Here is my code:

$url = "https://sp.name.com/sso/saml";

$filename = "saml1.xml";
$read = fopen($filename, "r");
$XML = fread($read, filesize($filename));
fclose
($read);
$XML_utf8 = utf8_encode($XML);
$XML64 = base64_encode($XML_utf8);
$data = "samlResponse=".$XML64."&relayState=https://sp.name.com/sso/saml";

$ch
= curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt
($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);



When I run this script on my service provider following errors messages generate:

SAMLSignOn failed: Failed to convert the base-64 encoded string into XML.
[Exception: SAMLSignOn failed: Failed to convert the base-64 encoded string into XML.]
[SAMLSerializationException: Failed to convert the base-64 encoded string into XML.]

I have already spent long time on this issue.

I’m not sure what the issue is. Your curl code looks ok but obviously something isn’t quite right.
At the service provider, please enable SAML trace and send the generated log file as an email attachment to support@componentspace.com mentioning this topic.
http://www.componentspace.com/Forums/17/Enabing-SAML-Trace