How to Log HTTP Requests with PHP

Note (2025): This post was written in 2010. The sample uses ereg, which has been deprecated in PHP 5.3 and removed as of PHP 7. Use preg_match or other modern approaches for production code. The article remains here for archival and historical interest. Sometimes you need to understand precisely how the HTTP request is submitted to the server. If you’re working with Salesforce.com, you probably don’t have easy or intuitive tools to understand how a message is serialized and sent by the runtime to the server. ...

May 27, 2010 · 1 min · Andrea Azzola

Consuming .NET Webservices Using PHP and NuSoap

In my scenario a .NET webservice offers particular encrypting capabilities. I need to consume the webservice with PHP by sending my plain string to get an encrypted one in return. The .NET webservice is working properly. I found the NuSoap library, and adopted it. Here the inclusion: require_once('lib/nusoap.php'); And here the code: // requires web service's specifications aka wsdl // $parameters: // requires following the array 'notation' // array('parameters' => (array('text' => 'Hello World!!!'))); // that equals to Hello World!!! // $proxy (->host, ->port, ->username, ->password) // optional, uses a proxy server function consume_webservice($wsdl, $method, $parameters, $debug = false, $proxy = null) { if ($proxy != null) $proxy->host = $proxy->port = $proxy->username = $proxy->password = false; $client = new soapclient($wsdl, true, $proxy->host, $proxy->port, $proxy->username, $proxy->password); $err = $client->getError(); if ($err) echo 'Constructor error' . $err; $result = $client->call($method, $parameters); // check for a fault if ($client->fault) { echo 'Fault'; print_r($result); } else { // check for errors $err = $client->getError(); if ($err) echo 'Error' . $err; } if ($debug) { echo 'Request' . htmlspecialchars($client->request, ENT_QUOTES); echo 'Response' . htmlspecialchars($client->response, ENT_QUOTES); echo 'Debug' . htmlspecialchars($client->debug_str, ENT_QUOTES); } return $result; } This approach works only with SOAP webservices. Please note that .NET web services include all response content into a “parameters” section by design. ...

October 23, 2007 · 1 min · Andrea Azzola