我正在尝试最终运行并在PHP应用程序中显示来自远程Jasper Server的报告。我想要做的是github上的jrs-rest-php-client项目。
错误:
DataTable
我的PHP:
Fatal error: Uncaught exception 'Jaspersoft\Exception\RESTRequestException' with message 'An unexpected HTTP status code was returned by the server' in C:\xampp\htdocs\jrs\vendor\src\Jaspersoft\Tool\RESTRequest.php:409
Stack trace:
#0 C:\xampp\htdocs\jrs\vendor\src\Jaspersoft\Tool\RESTRequest.php(479): Jaspersoft\Tool\RESTRequest->handleError(0, Array, false)
#1 C:\xampp\htdocs\jrs\vendor\src\Jaspersoft\Service\ReportService.php(40): Jaspersoft\Tool\RESTRequest->prepAndSend('https://jasper....', Array, 'GET', NULL, true)
#2 C:\xampp\htdocs\jrs\report.php(30): Jaspersoft\Service\ReportService->runReport('/Reports/Distri...', 'html')
#3 {main} thrown in C:\xampp\htdocs\jrs\vendor\src\Jaspersoft\Tool\RESTRequest.php on line 409
有什么想法吗?
答案 0 :(得分:1)
查看RESTRequest.php的代码,有两种情况会抛出此异常:
所以我怀疑连接不正常。要了解更多信息,您应该在代码中捕获异常并对其进行评估:
它可能看起来像这样(我对Java更熟悉):
try {
$d = new Client(
"http://jasper.server.com/jasperserver-pro",
"username",
"password",
"organization"
);
$info = $d->serverInfo();
} catch (RESTRequestException $e) {
echo 'RESTRequestException:';
echo 'Exception message: ', $e->getMessage(), "\n";
echo 'Set parameters: ', $e->parameters, "\n";
echo 'Expected status code:', $e->expectedStatusCodes, "\n";
echo 'Error code: ', $e->errorCode, "\n";
}
如果仍有错误,您可以查看以下内容: