There is a Java service that I need to invoke from PHP that looks something like this:
getProductsForMode(java.util.Calendar date, int modeId)
I'm having trouble mapping my PHP date class to the java.util.Calendar class. I've tried a couple different approaches, all to no avail:
Approach #1 (wrapping DateTime object in a CalendarHandle that gets mapped to Java's CalendarHandle):
class CalendarHandle
{
public $type;
public $date;
function __construct($date=null)
{
$this->date = $date;
}
}
$this->hessianClient = new HessianClient(_HESSIAN_ENDPOINT, $hessianOptions);
$config = &HessianConfig::globalConfig();
$config->typeMap->mapRemoteType('com.caucho.hessian.io.CalendarHandle', 'CalendarHandle');
$time = new CalendarHandle(new DateTime($dateEvaluated));
$products = $this->hessianClient->getProductsForMode($time, 1234);
Error:
[06-Jul-2011 11:16:52] PHP Fatal error: Uncaught exception 'HttpError' with message 'HttpError: Malformed HTTP header' in /Users/jordanb/Sites/proposal-framework/trunk/plugins/srHessianClientPlugin/hessianphp/Http.php:265
Approach #2: Mapping DateTime to java.util.Calendar
$this->hessianClient = new HessianClient(_HESSIAN_ENDPOINT, $hessianOptions);
$config = &HessianConfig::globalConfig();
$config->typeMap->mapRemoteType('java.util.Calendar', 'DateTime');
$time = new DateTime($dateEvaluated);
$products = $this->hessianClient->getProductsForMode($time, 1234);
Error:
[06-Jul-2011 11:28:50] PHP Fatal error: Uncaught exception 'HessianError' with message 'Hessian Parser, Malformed reply: expected r' in /Users/jordanb/Sites/proposal-framework/trunk/plugins/srHessianClientPlugin/hessianphp/Protocol.php:350
Has anyone had success sending a DateTime or some sort of timestamp from PHP to Java using Hessian? Thanks in advance!