Jaspert report get data from provider with web service. How to?

There is system, that has data, and can provide it’s data with web-services (for example Lotus Notes database). Can Jasper get data for it’s report by calling web-service?

Add Comment
4 Answer(s)

You can, but it will probably get very complicated very quickly. But if you want to travel that path, it is definitely possible with a JRXmlDataSource. You will have to define the datasource like:

new net.sf.jasperreports.engine.data.JRXmlDataSource( net.sf.jasperreports.engine.util.JRLoader.getLocationInputStream("http://yourserver.com/xml_data_source") 

See this post, where someone seems to have embarked on a similar quest, to retrieve xml data from a remote server for the report.

That being said, it will probably be a lot less work, and your code will probably be a lot more maintainable if you fetch the data from the server in your code, select the fields you want for your report and pass it in as, say, a JRMapCollection datasource, especially if the remote service offers a wsdl against which you could generate a client using a tool like Apache Axis.

Add Comment

The better solution right now is to use Jasper data source SPI to make your Restful services as data source just like JDBC data sources.

http://javattitude.com/2015/07/30/using-rest-web-service-as-data-source-for-jasper-reports/

One written this will work for all you services since this is generic.

Add Comment

This is now possible using Web Service Datasource

http://community.jaspersoft.com/project/web-service-data-source

This Community project implement a Custom Datasource, built using the latest Custom Datasource framework (leveraging Data Adapters internally).

It is also working inside JasperReports Server:

You can use it to fill Query based Input Controls, as well as Ad Hoc Reporting (for Commercial version) using it through Topic.

Thanks

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.