Search code examples
web-servicesrestjasper-reportsdatasourcejasperserver

How to pass data [json/xml] to the report deployed on JasperReports Server via Web Services?


I have developed a template design in JasperSoft Studio. I can upload the template code, if necessary. The template that I created using a connection to PostgreSQL database via JDBC for filling the report. Then I picked up the local JasperReports Server and download the template on the server. In this regard, I have a few questions.

  1. Can I use as the data json or xml (instead JDBC)?
  2. How I can pass the data (json or xml) to a template stored on the server, using Web Services?
  3. Could not you make a simple example in python?

Solution

    1. Yes, you need to use a JSON or XML Data Adapter. You can create a Data Adapter in Jaspersoft Studio and then deploy it in JasperReports Server. Although not stated in that tutorial, you also need to upload the JSON or XML file with the actual data, file that is referenced in the Data Adapter.

    A good example of how your files should look like is the Table Report report on the /reports/interactive path of the repository. If you inspect the report with Jaspersoft Studio' Repository Explorer you will see that the report uses the CSV Data Adapter from the same folder. If you open that adapter file you will see that it uses the CSV Data file from the same folder.

    1. JasperReports Server provides RESTful services with which you interact with the Server resources(reportUnits, inputControls, file resources, etc.). With these services, you do not alter the design of the report template. Once you have figured out, from point #1, what you need to have in your template and you have created your adapter file(an XML file), you can use the Repository service to upload your files.

    2. I think there are plenty of resources out there describing how to make requests to RESTful services in python. This one could be a start: Making a request to a RESTful API using python