Forgive my ignorance with such matters, but I have what is probably a simple issue that I can't seem to resolve on my own. I'm getting this error when sending a request to the SOAP server

org.xml.sax.SAXParseException: Content is not allowed in trailing section.

I've checked the end of all my .xml documents, and none have even a single space after </root tag>. Here's what I've got as going.



$data = fopen('php://input','rb');

$content = stream_get_contents($data);

if ($content)

$con = mysql_connect($hostname,$username, $password);
mysql_select_db($dbname, $con);

/*Connect To Database
if (!$con)
  die('Unable to connect to database! Please try again later.');

mysql_query("INSERT INTO basicInventory VALUES ($dwin_data['Id'], $dwin_data['Annual_Rent__c'], $dwin_data['Cap__c'], $dwin_data['City__c'], $dwin_data['Metro_Area__c'], $dwin_data['Options__c'], $dwin_data['Price__c'], $dwin_data['Remaining_Years__c'], $dwin_data['State__c'], $dwin_data['Status__c'], $dwin_data['Tenant__c'])");


//login script to salesforce for the $client variable ***change this path
require_once ('sfdc-client.cert');

// setup an array for the data coming in from the SOAP message
$dwin_data = array();

$dom = new DOMDocument();
$resultArray = parseNotification($dom);

// Data from SOAP message.
* This is where you do all your coding                   *
* and process the incomingin record as                   *
* need.  use the code:                                   *
* $temp = '<pre>' . print_r($dwin_data,true) . '</pre>'; * 
* mail('youremail@address.com', 'Suject', $temp);        *     
*                                                        *
*  To test to make sure you are getting the              *
*  data in an email, change the email address            *
foreach ($resultArray['MapsRecords'] as $dwin_data)

$temp = '<pre>' . print_r($dwin_data,true) . '</pre>';
mail('xxxxxxx@xxxxxxx.xxxxxxx', 'Suject', $temp);


foreach ($resultArray['MapsRecords'] as $dwin_data)
	$insert="INSERT INTO basicInventory ($resultArray) VALUES ('$dwin_data')";
	mysql_query($insert) OR die(mysql_error());


//clean all the data and then exit

/* Parse a Salesforce.com Outbound Message notification SOAP packet
* into an array of notification parms and an sObject.   */
function parseNotification($domDoc)
    // Parse Notification parameters into result array

    $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;

    // Create sObject and fill fields provided in notification
    $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;
            $tempMapRecord[$node->localName] = $node->textContent;

    // Finish last item
    $result["MapsRecords"][] = $tempMapRecord;

    return $result;
} // end parseNotification

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">
           <notifications xmlns="http://soap.sforce.com/2005/09/outbound">

//this is the funciton to query salesforce objects to gather data
//from different fields coming in from the SOAP message
function get_records(&$connection,&$query)
    $queryOptions = new QueryOptions(2000);

    $response = new QueryResult($connection->query($query));
    // if the size is zero, where done
    if ($response->size > 0)
        $products = $response->records;
        // Cycles through additional responses if the number of records
        // exceeds the batch size
        while (!$response->done)
            $response = $connection->queryMore($response->queryLocator);
            $products = array_merge($products,$response->records);
    return $products;



// change these paths to your fully qualified paths for each script to include
require_once ('SforcePartnerClient.php');
require_once ('SforceHeaderOptions.php');

// Login to salesforce.com
$login = "xxxxxxx";
$password = "xxxxxxx";

// change this paths to your fully qualified paths for the script to include
$wsdl = "sforce.wsdl.xml";

$client = new SforcePartnerClient();
    $loginResult = $client->login($login, $password);
    if ($loginResult->passwordExpired)
        $client = null;
catch (exception $e)
    $client = null;

If it helps, this is my objective: To send a SOAP request from salesforce to our website, which will use the values within the request to push data from salesforce to our website database. The returned information wont be used, so as long as it's a valid return, it doesn't matter.

It's worth noting that the section that emails the data from the request to me works just fine, and it all arrives looking correct

   [Id] => a0AA0000001B48bMAC
   [Annual_Rent__c] => 258000.0
   [Cap__c] => 9.0
   [City__c] => Jackson
   [Metro_Area__c] => Nothrbrook
   [Options__c] => 32.0
   [Price__c] => 3166000.0
   [Remaining_Years__c] => 18.0
   [State__c] => Mississippi
   [Status__c] => Available
   [Tenant__c] => Walgreens

Any help you could give would be most appreciated, and again, forgive my ignorance and any forum faux pas.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.