Page 1 of 1

SOAP Request and Response Envelopes

Posted: Fri Sep 14, 2007 12:25 am
by jeffery
I am working with Webservices and while connecting to a SOAP server I am able to execute the following code:

Code: Select all

$client = new SoapClient('wsdl_location', array("trace" => true, "exceptions" => true, 'soap_version' => SOAP_1_2));

// And for debuging the request and response I do this:

		if ($debug)
		{
			print "<pre>\n";
			print "Request :\n".htmlspecialchars($client->__getLastRequest()) ."\n";
			print "Response:\n".htmlspecialchars($client->__getLastResponse())."\n";
			print "</pre>";
		}
But I want to do logging of requests and responses at the Server End. For example at the Server end I can do the following:

Code: Select all

// Int theConstructor of the Webservices class I have:
$xml_request = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : file_get_contents("php://input");
The above gets me the Soap Request Envelope. Now I also want to capture whats going out as the SOAP response. But I am stuck. Any suggestions?

Posted: Fri Sep 14, 2007 12:49 am
by mrkite
If you want to see what's really going on. Run something like tcpflow on either the client or the server.

Posted: Fri Sep 14, 2007 12:57 am
by jeffery
No I need to log into the database what is being requested and the response to it. tcpflow maybe good for real time monitoring.

Posted: Fri Sep 14, 2007 1:17 am
by mrkite
jeffery wrote:No I need to log into the database what is being requested and the response to it. tcpflow maybe good for real time monitoring.
Oh, I see. You could use ob_start() to run the output of the script through a callback.. I believe the SOAP response would get sent through it.

Posted: Fri Sep 14, 2007 1:42 am
by jeffery
mrkite wrote:
jeffery wrote:No I need to log into the database what is being requested and the response to it. tcpflow maybe good for real time monitoring.
Oh, I see. You could use ob_start() to run the output of the script through a callback.. I believe the SOAP response would get sent through it.
ah damn.. why didn't I think of that... Thanks mrkite Problem Solved :)