Salesforce/PHP - outbound messages (SOAP) - memory limit issue? DOMDocument::loadXML() issue?

Posted by Phill Pafford on Stack Overflow See other posts from Stack Overflow or by Phill Pafford
Published on 2010-03-17T14:04:03Z Indexed on 2010/03/17 15:21 UTC
Read the original article Hit count: 190

I'm using Salesforce to send outbound messages (via SOAP) to another server. The server can process about 8 messages at a time, but will not send back the ACK file if the SOAP request contains more than 8 messages. SF can send up to 100 outbound messages in 1 SOAP request and I think this is causing a memory issue with PHP. If I process the outbound messages 1 by 1 they all go through fine, I can even do 8 at a time with no issues. But larger sets are not working.

ERROR in SF:

org.xml.sax.SAXParseException: Premature end of file

Looking in the HTTP error logs I see that the incoming SOAP message looks to be getting cut of which throws a PHP warning stating:

DOMDocument::loadXML() ... Premature end of data in tag ...

PHP Fatal error:

Call to a member function getAttribute() on a non-object

This leads me to believe that PHP is having a memory issue and can not parse the incoming message due to it's size.

I was thinking I could just set:

ini_set('memory_limit', '64M'); // This has done nothing to fix the problem

But would this be the correct approach? Is there a way I could set this to increase with the incoming SOAP request dynamically?

UPDATE: Adding some code

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

$headers = getallheaders();
$content_length = $headers['Content-Length'];
$buffer_length = 1000;
$fread_length = $content_length + $buffer_length;

$content = fread($data,$fread_length);

/**
 * Parse values from soap string into DOM XML
 */
$dom = new DOMDocument();
$dom->loadXML($content);
....

© Stack Overflow or respective owner

Related posts about salesforce

Related posts about php