Skip to content

Instantly share code, notes, and snippets.

@sylvainraye
Created October 17, 2013 11:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sylvainraye/7023225 to your computer and use it in GitHub Desktop.
Save sylvainraye/7023225 to your computer and use it in GitHub Desktop.
SOAP Client debugging with Zend Debugger
<?php
/**
* Class based on the blog article of Maxune.com
*
* @category Diglin
* @package Diglin_Debug
* @copyright Copyright (c) 2013 Diglin GmbH - Switzerland
* @license none
* @version 1.0.0
* @link http://moxune.com/blog/2011/09/debug-soap-server-zend-studio/
* @author Sylvain Rayé
* @since File available since Release 1.0.0
*/
/**
*
* A class to help you to debug the SoapServer script side
* You must have ZendDebugger and ZendStudio correctly configured to debug PHP scripts
* Replace in the sample the host with your own IP host
*
* <pre>
* $sUrl = 'http://www.mydomain.com/soap.php?wsdl';
* $client = new Diglin_Debug_SoapClient($sUrl);
* $client->setUserAgent('');
* $client->setDebugCookie(
* 'ZDEDebuggerPresent=php,phtml,php3; ' .
* 'debug_host=192.168.65.100,127.0.0.1; ' .
* 'debug_fastfile=1; ' .
* 'debug_port=10137; ' .
* 'start_debug=1; ' .
* 'start_profile=0;'
* 'send_debug_header=1; ' .
* 'send_sess_end=1; ' .
* 'debug_jit=1; ' .
* 'original_url=' . $sUrl . ';' .
* 'debug_stop=1; ' .
* 'use_remote=1; ' .
* 'debug_session_id=130607932'
* );
*
* $client->mySoapMethod($myArguments);
* </pre>
*/
class Diglin_Debug_SoapClient extends SoapClient
{
private $_sUserAgent;
private $_sDebugCookie;
public function setUserAgent($sUserAgent)
{
$this->_sUserAgent = $sUserAgent;
}
public function setDebugCookie($sCookie)
{
$this->_sDebugCookie = $sCookie;
}
public function __doRequest($request, $location, $action, $version, $one_way=0)
{
$aHeaders = array(
'Method: POST',
'Connection: Close',
'User-Agent: ' . $this->_sUserAgent,
'Content-Type: text/xml',
'SOAPAction: "'.$action.'"',
'Cookie: ' . $this->_sDebugCookie
);
$ch = curl_init($location);
curl_setopt_array(
$ch,
array(
CURLOPT_VERBOSE => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $request,
CURLOPT_HEADER => false,
CURLOPT_HTTPHEADER => $aHeaders,
CURLOPT_SSL_VERIFYPEER => false,
)
);
return curl_exec($ch);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment