Recent Changes - Search:



Related Projects

Powered by PmWiki


There are several options you can configure in HessianPHP clients using the static methods of the Hessian class.

General client configuration

Some old functions like setURLOption() and setCredentials() were removed in favor of a more general way to configure cients. Just like PHP5's SOAP library, you can pass an associative array to the constructor of the client object to set several different options. Available options are:

  • 'username' Pass a string to set the username for Basic http authorization method (See setCredentials() method)
  • 'password' Pass a string to set the password for Basic http authorization method.
  • 'timeout' Pass an integer value representing the number of seconds the connection should wait before it times out and generates a HessianError.
  • 'proxy_user' Username for proxy server
  • 'proxy_pass' Password for proxy server
  • 'proxy_host' Hostname or ip address of proxy server
  • 'proxy_port' Port number for proxy server
  • 'methods' Comma separated names of remote methods of the service, see below

For example, if you want to call a service protected with basic security and set a timeout of 10 seconds for the connection:

$options = array('username' => 'myuser', 'password' => 'mypass', 'timeout'=>10);
$client = new HessianClient($url,$options);

Mapping the name of a remote method



$options = array(
    'methods' => 'method1,method2'

This is often necessary to do in php4 for the name of local dynamically called methods are always converted to lower case and the names in remote services are usually camel cased (Java and C# for example). So if you know that a remote method is camel cased, you need to tell HessianPHP it's real name before you execute the call, like this:


This is not needed in php5.

Mapping of remote types to local php classes

Objects and hashtables that come from a remote service are deserialized into an associative array by default, but you can specify that certain types are deserialized into local php objects of an specific type, for example:

To deserialize the remote type 'hessiantest.User' that comes from a Java Service into a custom User class:


This classes need to have a default 0 argument constructor (the default for php), what's called bean-style class in Java.

Error handling

Now you can select how HessianPHP will react when an error is detected. When a trappable error occurs (or a fault), you can always check the returned value of the error() method that returns a HessianError object if there is an error or false otherwise.

There are four constants that can be passed to the errorReporting() function:

  • HESSIAN_SILENT: No action is taken. This is the default behavior for the php4 version.

  • HESSIAN_EXCEPTION: An exception is thrown, the exception object is the same object that returns from a call to error(). This option is only available when using HessianPHP in php5.

  • HESSIAN_TRIGGER_NOTICE: A PHP 'notice' will be shown when this option is set.

  • HESSIAN_TRIGGER_ERROR: A PHP 'fatal' error will be triggered when this option is set, this halts the execution of the rest of the script.

For example Hessian::errorReporting(HESSIAN_TRIGGER_ERROR);.

This last two options are usefull when you have defined a custom error handler routine with set_error_handler().

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

PmWiki can't process your request

Cannot acquire lockfile

We are sorry for any inconvenience.