Just a quickie. Do you ever want to debug an RPC call to XML-RPC or Soap or something like that using Zend Studio/PDT and the Zend Debugger? What I mean is debug the RPC call, not the request making the RPC call. Doing that is actually quite simple. I have some code here to share that I recently (as in 5 minutes ago, used).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | $options = Zend_Registry::get('Zend_Application')->getOption('xmlrpc'); $this->_xmlrpc = new Zend_XmlRpc_Client( $options['server']. '/service' ); if (false) { $http = $this->_xmlrpc->getHttpClient(); $http->setCookie('start_debug', '1'); $http->setCookie('debug_stop', '1'); $http->setCookie('debug_fastfile' ,'1'); $http->setCookie('debug_coverage' ,'1'); $http->setCookie('use_remote' ,'1'); $http->setCookie('send_sess_end' ,'1'); $http->setCookie('debug_session_id' ,'2000'); $http->setCookie('debug_start_session' ,'1'); $http->setCookie('debug_port', '10137'); $http->setCookie('debug_host', '127.0.0.1'); } |
What this does is get the HTTP client from XML-RPC (or anything else that uses Zend_Http_Client) and adds a bunch of cookies as defined in the Zend Knowlege Base. If I want to debug I just change the condition (if (false)) to true and re-run the request. Since the Zend Debugger listens for cookies that are named like this, once it sees those cookies, the debug request will be initiated.
A few words on the ones you need to know:
- start_debug – Tells the debugger to actually debug the request. The debug session will not start without this. Why not just run the request? Because there’s also a start_profile which can be used to profile a request instead of debug it
- debug_session_id – This is considered optional, but if you are getting an error saying that the protocol is wrong change this to a number that has not been used
- debug_port – The port Zend Studio/PDT is listening on. It’s probably 10137.
- debug_host – The host that Zend Studio/PDT is on. The debugger works by initiating a TCP connection back to Zend Studio and so this IP address ( or comma seperated list) is needed to tell the debugger where to go.
Comments
insekticid
great post, thank you!
Bas
So where should I place this code?
On the soap client side I reckon?
I am in the process of trying to get debugging with breakpoints etc.. working for my local environment.
Kevin Schroeder
That is correct. On the client side of the application