我正在尝试最终运行并在PHP应用程序中显示来自远程Jasper Server的报告。我想要做的是 jrs-rest-php-client 在github上的项目。
I am trying to ultimately run and display reports from a remote Jasper Server in a PHP application. What I am trying to do this with is the jrs-rest-php-client project on github.
错误:
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('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我的PHP:
require_once __DIR__ . "/vendor/autoload.php"; use Jaspersoft\Client\Client; $d = new Client( "jasper.server/jasperserver-pro", "username", "password", "organization" ); $info = $d->serverInfo();任何想法?
推荐答案查看 RESTRequest.php 有两种情况会引发此异常:
Looking into the code of RESTRequest.php there are two cases in which this exception is thrown:
- 一个JSON结果集返回未知错误代码(未知含义与200 OK不同)
- 根本不返回任何JSON结果集
所以我怀疑连接不正常。要了解更多信息,您应该在代码中捕获异常并对其进行评估:
So I suspect the connection isn't working properly. To find out more, you should catch the exception in your code and evaluate it:
它可能看起来像这样(我对Java更熟悉):
It could look something like this (I'm more familiar with Java):
try { $d = new Client( "jasper.server/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"; }如果仍有错误,您可以查看以下内容:
If there is still an error, you can check the following:
- 您可以从部署此代码的服务器到达jasper服务器吗?有时例如防火墙设置可能会干扰。
- 组织的调用是否与服务器中组织属性中的定义完全相同? (打开存储库/右键单击organization / properties / resource-id)
更多推荐
PHP JasperReports服务器API错误
发布评论