+ Reply to Thread
Page 2 of 2 FirstFirst 12
Results 11 to 12 of 12
This is a discussion on How to setup outbound message and receive the data in Mysql. within the Salesforce PHP Tutorials forums, part of the Salesforce category; Hi Mike, I have buy the MAGIC Parser, But how I parse
  1. #11
    nitin is offline Junior Member
    Join Date
    Mar 2011
    Posts
    7
    Hi Mike, I have buy the MAGIC Parser, But how I parse and grab data XML string data.

  2. #12
    Adam Best is offline Junior Member
    Join Date
    Apr 2011
    Posts
    10

    Post

    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
    Last edited by Adam Best; 04-20-2011 at 11:45 AM. Reason: Accidenlty put extra function in it.. just taking it out.

+ Reply to Thread
Page 2 of 2 FirstFirst 12

Similar Threads

  1. Salesforce/PHP - Bulk Outbound message (SOAP), Time out issue
    By ppafford in forum Salesforce Coding Discussions
    Replies: 8
    Last Post: 03-23-2010, 08:28 AM
  2. xampp new install - toolkit setup issue
    By nrwingate in forum Salesforce Coding Discussions
    Replies: 4
    Last Post: 10-21-2009, 05:24 PM
  3. Outbound Messages + Merge Records
    By ambiguator in forum Salesforce PHP Tutorials
    Replies: 10
    Last Post: 09-29-2009, 01:24 PM
  4. how to receive user data from salesforce to php
    By lucasvm in forum Salesforce Coding Discussions
    Replies: 1
    Last Post: 01-15-2009, 08:27 PM
  5. Replies: 9
    Last Post: 08-22-2007, 08:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

SEO by vBSEO 3.5.2