I have developed a template design in JasperSoft Studio and upload jrxml
file to JasperServer. I want to send data (JSON or XML) to filling report template from my python application and take back report in some popular formats like PDF, XLS using REST API. I do not want to store the data on the server. How can I do this? Or data must be stored on the server and there is no alternative way of their transmission by WEB-Service?
相关问题
- Design RESTful service with multiple ids
- Axios OPTIONS instead of POST Request. Express Res
- Plain (non-HTML) error pages in REST api
- Laravel 5.1 MethodNotAllowedHttpException on store
- Jasper: error opening input stream from url
相关文章
- Using JAX-WS 2.2.5 client with JDK/JRE 1.5
- Cannot use org.jvnet.jax-ws-commons.jaxws-maven-pl
- Got ActiveRecord::AssociationTypeMismatch on model
- Multiple parameters in AngularJS $resource GET
- How to create base64Binary data?
- Global Exception Handling in Jersey & Spring?
- Are there any public UDDI registries available?
- REST search interface and the idempotency of GET
The data does not necessarily have to reside on the server.
You could design your template in such way that you can pass the data via input control parameters as @tobi6 suggested. Then you could use either the reports service or the reportExecutions service to get the desired output.
In your case, the data could be the actual data(XML or JSON) or the source of the data(a URL to the data file).
Here are some basic samples for working with XML data(for JSON is quite similar):
With actual data as parameter
The JasperReports template:
After you deploy the report and create the input control for the
xmlString
parameter you can test it. Let's say you want to pass this XML instead of leaving the default in place:To test the reports service you run something similar to this in a terminal(I URL-encoded the XML string) and check the result:
To test the reportExecutions service, the main steps are:
1.Create an XML file with the request(name it
reportExecutionRequest.xml
)2.Make the request(you need to save the session cookie to retrieve the output):
3.Get the output with the
requestID
andexportID
from the result of the previous request:With data as source URL
It is the same report template, but with the two parameters replaced with:
Note: I created two parameters here just because I wanted to keep a shorter name for the parameter when passing it through the reports service. I also created an input control just for the
xmlSource
parameter.The tests in this case are similar.
EDIT: To use JSON instead of XML, the original JasperReports template needs to be adjusted in this way:
For data as parameter, just change the
xmlString
parameter, theXML_INPUT_STREAM
parameter and thequeryString
to this:For data as source URL, change the
xmlString
parameter, theXML_INPUT_STREAM
parameter and thequeryString
to this:The cURL tests for the REST services are basically the same with the main difference that you will be passing JSON instead of XML and use the JSON specific parameters
jsonString
orjsonSource
.The API is separated in three domains:
To generate reports, they first have to be deployed to the server via the repository service. If later on the report needs to be generated, it is called via the report services. Here, it is also possible to start synchronous or asynchronous report generation.
Therefore the report needs to be in the repository.
EDIT
Since you also need to deliver parameters, referring to this example it would work like this:
http://<host>:<port>/jasperserver[-pro]/rest_v2/reports/reports/samples/EmployeeAccounts.html?EmployeeID=sarah_id