简体   繁体   中英

PHP - capture SOAP response using ob_*

I'm sending a ACK response back to a SOAP request (via Salesforce) and I would like to capture what I'm sending back to SF. Now I seen some stuff online that uses ob_start (or one of the ob_ functions) to record the response but I've never used ob_ before and after Googling for a while didn't find anything I could use/follow.

The Problem: Salesforce sends an outbound message to my server via SOAP, I process the message and send back a ACK file to SF. I want to log/record the message (and anything else) I'm sending back to SF. How can I do this?

Yes, anything you write to the output buffer can be captured using

ob_start();
// create and send your SOAP message
// ...
$mystring = ob_get_contents(); // retrieve all output thus far
ob_end_clean ();               // stop buffering
log($mystring);                // log it 
echo $mystring;                // now send it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM