Jump to content
We've recently updated our Privacy Statement, available here ×

Jasperreport with restful webservice as datasource


mihir_3

Recommended Posts

Hi Experts,

I am newbie to jaspersoft. I have a requirement to create report using RESTful webservice as a datasource. The provided RESTful webservice can accept parameters for filters either through GET/POST/PUT/DELETE methods and respond in XML/JSON format. I am unable to find a way to pass the user inputs as parameter to RESTful webservice.

Using s/w version- jaspersoft studio 6.1.0, jasperreprt server 6.1.0

Any leads is appreciated. Thanks in advance.

-Mihir

Link to comment
Share on other sites

  • Replies 8
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Hi,

I used JasperReports Server REST_v2 web-service to test your scenario and to pass required organization name as a parameter.


So, what I did:

  1. In Jaspersoft Studio create new data adapter using 'XML document' type and specify JasperReports Server REST organizations service URL for File field
    and select 'Use the report Xpath expression when filling the report' option: 

    http://localhost:8090/jasperserver-pro/rest_v2/organizations?j_username=superuser&j_password=superuser
     
  2. Create a new report using the new dataadapter with Xpath expression:

    /organizations/organization

    Run the report to verify how it works. It should return all existing organizations in JasperReports Server
     
  3. Create a new parameter with java.lang.String type, for example p_org, and then modify Xpath expression to

    /organizations/organization[id=$P{p_org}]
     
  4. Run the report, enter organization_1 as the parameter value. The report returns 1 record for organization_1
     

Here you can find a short summary how to use Xpath expression to filter data:

http://www.w3schools.com/xml/xml_xpath.asp

Hope this help you to implement your task

Link to comment
Share on other sites

I have the same requirement but have found no way to do it. I tried several methods that use xpath2 and a parameter named XML_URL, but JapersoftStudio does not supportxpath2 anymore. I also tried a suggest where you create a parameter named net.sf.jasperreports.data.adapter and pass that in, but that didn't work either. If you find a solution, let me know and I will do likewise.

 

Dan

Link to comment
Share on other sites

Somehow we are able to do. we have tried a method that use xpath2 and a parameter named XML_URL. Since Latest jasper doesn't support xpath2 so we need to tweak two things

  1. Drop jasperreports-extensions-3.5.3.jar file to "..XXXXXXXXXXjasperserverWEB-INFlib"
  2. Browse to "..XXXXXXXXjasperserverWEB-INFclassesjasperreports.properties"
  • Add the following line of code to properties file
  • net.sf.jasperreports.query.executer.factory.xpath2 = com.jaspersoft.jrx.query.JRXPathQueryExecuterFactory

Restart tomcat

After above configuration xpath2 functionality can be achived and it resolved our issue.

Cheers

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...