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

谁说胖子不能爱 提交于 2020-07-16 04:25:51

问题


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?


回答1:


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.




回答2:


You can write a custom DataSource by implementing the interface JRDataSource.

Full explanation: http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/sample.reference/datasource/index.html#customdatasource.




回答3:


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.




回答4:


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



来源:https://stackoverflow.com/questions/10704216/jaspert-report-get-data-from-provider-with-web-service-how-to

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!