Recent Changes - Search:

Documents

Community

Related Projects

Powered by PmWiki

Debugging HessianPHP

HessianPHP includes a few debugging facilities to help you out develop Hessian based web services.

The safest bet when creating or consuming services in PHP is to create a test front end that performs local calls on the published operations. On the other hand, you might want to take a look at the deepest aspects of the Hessian protocol, this is the raw dump of the byte stream.

HessianPHP comes with three facilities that can help you out here when debugging clients.

LogFilter

This filter, when enabled, will create a text entry each time you create a proxy or call a remote operation or an error is detected. Although its information is very brief, you can check a dump of this log just to see if all calls went fine. For example:

// Register the filter (global way)
Hessian::addFilter(new LogFilter());
// ... perform some work

// Now watch the dump
print_r( LogFilter::getMessages() );

You can always create a more advanced filter that captures more output from the framework as explained in Filters.

StreamDumpFilter

If you want to save the real bytes sent and received in a remote call, you can enable StreamDumpFilter, add some configuration parameters and check a raw Hessian protocol file dump.

StreamDumpFilter must be configured for every client you create using the $options array. The configurable parameters are:

  • out_stream_file Name of the file where the outgoing payload will be saved
  • in_stream_file Name of the file where the incoming payload will be saved
  • dump_mode How to save the stream to the file. Can have two values: 'save' (default) will create a new file for every remote call and 'append' will use the same file and append the byte stream to it.
  • dump_detail Level of detail information to be saved, can be 'simple'(default) which just saves the stream or 'advanced' which saves the url, name of the method and time of calling along side with the stream in the file.

Example:

$options = array(
'out_stream_file'=>'out_php.bin',
'in_stream_file'=>'in_php.bin',
'dump_mode'=>'append',
'dump_detail'=>'advanced',
'filters'=>
	array(
		'dump'=>new StreamDumpFilter(),
	)
);

$proxy = &new HessianClient($url, $options );

All incoming bytes will be saved to in_php.bin at the script directory and also, all output bytes will be stored in out_php.bin. Every call will be appended to the next in a detailed fashion.

If you are working with raw byte streams it is recommended that you use an hexadecimal editor such as Hawk for this task.

Hessian error log

Internally, HessianPHP uses a stack to log all errors during script execution. The Hessian::error() global function will return the *last* error occurred in the session, which sometimes is enough to correct the situation.

However, if you are calling mulitple methods and an error is present, you might want to know which function caused it and would like to have access to the entire error stack, so you can call Hessian::getErrorStack() that will return an array of error objects for the current script.

Each error object contains basic information about the error such as a message, a code, time of the error and, depending on the type of error, the raw Hessian byte stream involved or the HTTP response headers and body.

In PHP 5, all HessianPHP errors are also Exceptions by default, so you will also get an stack trace of execution that can be accessed just echoing the error.

By combining these three facilities, you can quickly find out what is causing a misbehaviour in your HessianPHP clients or services. As development advances, many of these facilities will be revisited and augmented.

For examples of these techniques, take a look at the files in the /unit_test folder in the distribution.

TODO: Debugging services, more examples

Edit - History - Print - Recent Changes - Search
Page last modified on January 03, 2006, at 04:43 AM

PmWiki can't process your request

Cannot acquire lockfile

We are sorry for any inconvenience.