Thanks for this great thread and all its contributors.
I'm currently receiving an outbound message and running a simple CURL function.
Everything works except for the notifications and while it doesn't affect my processing, it's probably best to address it instead of leaving Salesforce to repeatedly send the messages.
In Salesforce, I receive a (500) Internal Server Error in the message queue, but I have verified through file/email output that the data is being received and processed.
PHP Code:
<?php
error_reporting(0);
// Define a log location for archiving each request recieved
$log_location = "/myhost/httpdocs/salesforce/salesforceresponse.txt";
//Checks for presence of the cURL extension.
function _iscurlinstalled()
{
if (in_array ('curl', get_loaded_extensions()))
{
return true;
}
else
{
return false;
}
}
if (!_iscurlinstalled()) die("cURL is NOT installed.");
$data = fopen('php://input','rb');
$content = stream_get_contents($data);
if ($content)
{
respond('true');
}
else
{
respond('false');
}
$dom = new DOMDocument();
$dom->loadXML($content);
// Got DOM values directly
$Email = $dom->getElementsByTagName("Email")->item(0)->textContent; // GET SALESFORCE EMAIL FROM <sf:Email></sf:Email>
$FirstName = $dom->getElementsByTagName("FirstName")->item(0)->textContent; // GET SALESFORCE FIRST NAME FROM <sf:FirstName></sf:FirstName>
$LastName = $dom->getElementsByTagName("LastName")->item(0)->textContent; // GET SALESFORCE LAST NAME FROM <sf:LastName></sf:LastName>
$SForceId = $dom->getElementsByTagName("Id")->item(1)->textContent; // GET SALESFORCE ID FROM <sf:Id></sf:Id>
// Start my CURL function
// ...
// End my CURL function
//login script to salesforce for the $client variable ***change this path
require_once ('/myhost/httpdocs/salesforce/includes/sfdc.inc');
//clean all the data and then exit
exit;
//functions
/* Parse a Salesforce.com Outbound Message notification SOAP packet
* into an array of notification parms and an sObject. */
function respond($tf)
{
print '<?xml version = "1.0" encoding = "utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body>
<notifications xmlns="http://soap.sforce.com/2005/09/outbound">
<Ack>'.$tf.'</Ack>
<notifications>
</soapenv:Body>
</soapenv:Envelope>';
}
?>
Is there anything I could be doing wrong?
Any help or information is greatly appreciated.
Bookmarks