我需要从 PHP 调用一个 Java 服务,它看起来像这样:
getProductsForMode(java.util.Calendar date, int modeId)
我无法将我的 PHP 日期类映射到 java.util.Calendar 类。我尝试了几种不同的方法,但都无济于事:
方法 #1(将 DateTime 对象包装在映射到 Java 的 CalendarHandle 的 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);
错误:
[06-Jul-2011 11:16:52] PHP 致命错误:在 /Users/jordanb/Sites/proposal-framework/trunk/plugins/srHessianClientPlugin/hessianphp/ 中带有消息 'HttpError: Malformed HTTP header' 的未捕获异常 'HttpError' http.php:265
方法 #2:将 DateTime 映射到 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);
错误:
[06-Jul-2011 11:28:50] PHP 致命错误:在 /Users/jordanb/Sites/proposal-framework/trunk/plugins/srHessianClientPlugin 中带有消息“Hessian Parser, Malformed reply: expected r”的未捕获异常“HessianError” /hessianphp/Protocol.php:350
有没有人使用 Hessian 成功地将 DateTime 或某种时间戳从 PHP 发送到 Java?提前致谢!