PHP JasperReports服务器API错误

编程入门 行业动态 更新时间:2024-10-21 23:24:41
本文介绍了PHP JasperReports服务器API错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试最终运行并在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错误

本文发布于:2023-11-26 18:22:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634675.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:错误   服务器   PHP   JasperReports   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!