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

前端 未结 4 1006
半阙折子戏
半阙折子戏 2021-01-23 02:37

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?

相关标签:
4条回答
  • 2021-01-23 02:58

    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.

    0 讨论(0)
  • 2021-01-23 03:10

    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.

    0 讨论(0)
  • 2021-01-23 03:18

    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.

    0 讨论(0)
  • 2021-01-23 03:25

    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

    0 讨论(0)
提交回复
热议问题