如何通过Jasper PHP/REST API将报告(jrxml文件)部署到Jasper Reports Server?
发布于 2013-07-19 17:07:02
要上传jrxml文件,需要创建一个PROP_HAS_DATA = true的ResourceDescriptor,并将jrxml内容插入到一个多部分的PUT请求中。
经过一段时间的研究和调查,我让它运行起来,并开发了一个易于使用的PHP类。
http://blog.flowl.info/2013/jasper-php-library-on-github/
要上传jrxml文件,此代码完成以下工作:
// Init the Jasper connection
require_once('Jasper/Jasper.php');
$jasper = new \Jasper\Jasper();
$jasper->login('jasperadmin', 'jasperadmin', 'jasper.host.com:8080');
// Create a Resource Descriptor object for the jrxml file
$jrxml = new \Jasper\JasperJrxml('/reports/test.jrxml');
// Upload the Resource Descriptor object with content
$jasper->createContent($jrxml, file_get_contents('templates/test.jrxml'));要创建报告单元,请使用以下行:
// Datasource Resource Descriptor
$mongo = new \Jasper\JasperDatasource();
$mongo->setPropIsReference('true');
$mongo->setPropReferenceUri('/datasources/mongo_local_test');
// Put everything together and deploy the report
$report->addChildResource($mongo);
$report->addChildResource($jrxml);
// Want to see the Resource Descriptor of the Report Unit?
// true = pretty print
print_r($report->getXml(true));
// Create a the Report Unit
$jasper->createResource($report);https://stackoverflow.com/questions/17347906
复制相似问题