Hi Nitin,
I thought i might give you a step by step on how we have achieved Outbound Soap Messaging to a PHP Page to get the Id of the record being sent. Just follow step by step and see how you go. Don't forget to change the email addresses to your own email address.
This is Mike's example altered slightly - Thanks mike!
To start with here is the environment this is working on:
Apache version 2.0.63
PHP version 5.3.2
MySQL version 5.0.92-community
1) Setup Outbound Soap Message in SalesForce
Please visit this page which is a step by step with screen shots:
miiJoomla Salesforce To Website Intergration
This above example passes the Id of the record through to your PHP Script.
For your END POINT URL, this is the location that your PHP page is running on.
Example: www.yourdomain.com/mysoappage.php
2) Now Create your PHP Page above - use the following code:
PHP Code:
$data = fopen('php://input','rb');
$content = stream_get_contents($data);$dwin_data = array();
$dom = new DOMDocument();$dom->loadXML($content);
$resultArray = parseNotification($dom);unset($resultArray[sObject]);
foreach ($resultArray[MapsRecords] as $dwin_data)
{
####### THIS IS HOW YOU GET YOUR ID ##############
$SalesForceRecordId = $dwin_data[Id];
if(empty($dwin_data[Id])){
$temp = "FAILED";
mail('noreply@miiworks.com', 'Record Failed', $temp);
}else{
$temp = "UPDATED ID:$dwin_data[Id]";
mail('noreply@miiworks.com', 'Record Updated', $temp);
}
}
if($content){respond('true');}else{respond('false');}
unset($client);unset($dwin_data);unset($dwin_create);unset($records);
exit;
function parseNotification($domDoc)
{
$result = array("OrganizationId" => "","ActionId" => "","SessionId" => "","EnterpriseUrl" => "","PartnerUrl" => "","sObject" => null,"MapsRecords" => array());
$result["OrganizationId"] = $domDoc->getElementsByTagName("OrganizationId")->item(0)->textContent;
$result["ActionId"] = $domDoc->getElementsByTagName("ActionId")->item(0)->textContent;
$result["SessionId"] = $domDoc->getElementsByTagName("SessionId")->item(0)->textContent;
$result["EnterpriseUrl"] = $domDoc->getElementsByTagName("EnterpriseUrl")->item(0)->textContent;
$result["PartnerUrl"] = $domDoc->getElementsByTagName("PartnerUrl")->item(0)->textContent;
$sObjectNode = $domDoc->getElementsByTagName("sObject")->item(0);
$sObjType = $sObjectNode->getAttribute("type");
if (substr_count($sObjType,"sf:")){
$sObjType = substr($sObjType,3);
}
$result["sObject"] = new SObject($sObjType);
$result["sObject"]->type = $sObjType;
$sObjectNodes = $domDoc->getElementsByTagNameNS('urn:sobject.enterprise.soap.sforce.com','*');
$result["sObject"]->fieldnames = array();
$count = 0;
$tempMapRecord = array();
foreach ($sObjectNodes as $node){
if ($node->localName == "Id"){
if ($count > 0){
$result["MapsRecords"][] = $tempMapRecord;
$tempMapRecord = array();
}
$tempMapRecord[$node->localName] = $node->textContent;
}else{
$tempMapRecord[$node->localName] = $node->textContent;
}
$count++;
}
$result["MapsRecords"][] = $tempMapRecord;
return $result;
}
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>';
}
Let me know how you go.
Regards,
Adam
Into Joomla! and SalesForce?
Check us out at miiWorks - Joomla Extensions, SalesForce Apps, Business Apps, Web Hosting, Domains
Bookmarks