mariuss Posted November 7, 2013 Share Posted November 7, 2013 Hello Community,after reading the tutorials below:Build reports based on XML datasource using the iReport DesignerXML Datasources in Jaspersoft StudioXML DatasourcesRemote XML DatasourceUsing XML Datasource in JasperReports ServerI finally get a report with a remote xml data source to run on the server and to output it in the browser using the webservice rest_v2/reports/.What I didn't find in the tutorials, is how to pass a new value for the report parameter XML_URL and what webservice to use for. But it is mentioned something like:When the report is executed inside an application, the URL can be set dynamically with a parameter XML_URL.Does anybody have experience with passing the xml_url through a webservice and would be nice to point me in a direction? I'm using the JasperReports Server CE 5.2.0Thank you, Marius Link to comment Share on other sites More sharing options...
vote4me Posted November 15, 2013 Share Posted November 15, 2013 I am trying to do the same thing (but with version 5.5.0), and I have gotten 1/2 of the solution—namely, I can successfully pass the XML remote datasource to a JasperReport Server (JRS) parameter via a URL query string (not to be confused with JRS querystring). Unfortunately, while the report output recognizes my parameter, the report also thinks my remote data source is null... That may not have made sense, so here are my steps:1. Use Jaspersoft Studio to create a report using a remote XML as your datasource. Good tutorial here2. Manually edit the JRXML file to remove the statically defined remote datasource and replace it with two parameters (the first one is to capture the value as passed in your URL, and the second is the new (and supposedly dynamic) XML remote datasource: <parameter name="rss_feed" class="java.lang.String"/> <parameter name="XML_URL" class="java.lang.String"> <defaultValueExpression><![CDATA["http://somesite.com/" + $P{rss_feed}]]></defaultValueExpression </parameter>3. Send the report to the Jasper Report Server (JRS). Please note that you have to manually copy the xpath2 extension to JRS first if you have not already done so.4. View the input controls of the new report via the REST2 web service like so: http://localhost:8080/rest_v2/reports/reports/test/TEST_1/inputControls/values/?rss_feed=FOO5. Now here is the disconnect. The above API call returns XML that shows that my parameter rss_feed is correctly set to "FOO"; however, my XML_URL parameter does not contain that extra FOO. Hopefully, you can help us both figure it out. Link to comment Share on other sites More sharing options...
Solution vote4me Posted November 17, 2013 Solution Share Posted November 17, 2013 To understand this answer, please refer to the comment I made a couple of days ago. The report is working properly now by removing the rss_feed parameter and using XML_URL only. So in my jrxml file, the parameter now reads: <parameter name="XML_URL" class="java.lang.String"> <!-- If the XML_URL query string is not passed, default to a default XML remote source to prevent an empty report. --> <defaultValueExpression><![CDATA[$P{XML_URL} ? $P{XML_URL} : "http://somesite.com/somefeed.xml"]]></defaultValueExpression> </parameter> So now I can set the remote XML data source straight from the URL: http://localhost:8080/rest_v2/reports/reports/test/TEST_1.html?XML_URL=[whatever _URL] Now, that this works, if someone can point me on how I can create a new Remote JSON adapter, I would appreciate any feedback. Link to comment Share on other sites More sharing options...
mariuss Posted November 26, 2013 Author Share Posted November 26, 2013 hi :) and sorry for the delay, I didn't realize that I have an answer, I think that I accidently skiped that email. Thank you for sharing your experience with me and the community! Where did you find out, when we have to create an input control for the passed parameter, as you mentioned at step 4 and when not? Can you please point me on that part of the documentation, thx again. Your answer helps me a lot. First I got this Error: com.jaspersoft.jasperserver.api.JSExceptionWrapper: net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file: 1. Type mismatch: cannot convert from String to boolean value = ((java.lang.String)parameter_XML_URL.getValue()) ? ((java.lang.String)parameter_XML_URL.getValue()) :"http://your/server"... but then i realized that I have tho change the language used for the report expressions to javascript :) and now it works :) Concerning the JSON adapter I have just some links for you: http://community.jaspersoft.com/wiki/how-create-and-use-jrdatasource-adapter http://community.jaspersoft.com/wiki/how-create-and-use-jrdatasourceprovider-adapter http://community.jaspersoft.com/wiki/sample-report-using-json-data-source-deployed-jasperreports-server http://community.jaspersoft.com/wiki/how-query-file-based-json-datasource http://stackoverflow.com/questions/11536995/create-jasper-report-pdf-form-from-json-object-or-json-string/15518513#15518513 http://www.grantcurrey.com.au/blog/2013/01/26/using-jsondatasource-with-jasperreports/ Maybe it is better to open a new thread for that. So many thanks again :) Marius Link to comment Share on other sites More sharing options...
vote4me Posted November 26, 2013 Share Posted November 26, 2013 No worries, Marius. First, thanks for the links. Will research and probably open a new post. As for the input controls documentation, I only relied on the web and the JRS Web Services Guide, section 3.3, which does not explain much. Through trial and error, when I used JR Studio to create the report, I did NOT have to manually create the input control on the server afterward (as some other posts point out). In other words, as long I created the parameter in JRStudio, the parameter showed up in the report on the server--assuming you setup the syncing and checked the parameters to upload. On the other hand, as my first parameter does not seem to dynamically alter the second parameter (XML_URL), maybe I'm wrong about the whole input control concept! Also of note, the XML_URL is a built-in parameter that keys the remote XML data source so that's why my answer works. I hope I answered your question, but if not, drop me a line. Stephen... Link to comment Share on other sites More sharing options...
mariuss Posted November 27, 2013 Author Share Posted November 27, 2013 Hi Stephen, what do you mean with "assuming you setup the syncing and checked the parameters to upload"? After editing I publish the jrxml file on the jasper server since i have a JRS connection in my JR Studio. The only option checked is "Don't use any Data Source". Is there another workflow for doing that? Related to the JSON Adapter, you have on the JR Server a sample for a CSV Data Adapter under Reports/Interactive and http://jasperreports.sourceforge.net/sample.reference/csvdatasource/. And you can take a look at the Chapter 5(Custom Data Sources) of JasperServer Ultimate Guide: community-static.jaspersoft.com/system/files/documentation/js-ultimate-guide-5.0.pdf And here is another thread about data adapter: http://community.jaspersoft.com/questions/802580/how-create-excel-data-source-jasperreports-server I hope this can help you a little bit :) Marius Link to comment Share on other sites More sharing options...
vote4me Posted November 27, 2013 Share Posted November 27, 2013 Thanks again for the info. I'm referring to a step after I save/publish from JR Studio 5.5 to JR Server 5.5. Specifically, after I say "yes" to publish the report to the server, I then get a "Select Resources to publish" window to which I have to click on my parameters if I want to update them. If I do not check them, any parameter changes are lost. Here's a screencap from my JRStudio screen: http://imgur.com/FgFNxkJ Link to comment Share on other sites More sharing options...
mariuss Posted December 6, 2013 Author Share Posted December 6, 2013 Thank you Stephen, your answers are very helpful for my start with jasper. Did you manually insert the xml_url param in the jrxml file? I do it like this: ]]></parameterDescription></p><p> <defaultValueExpression><![CDATA[$P{XML_URL} ? $P{XML_URL} :"http://server:8080/nav/xml/test/Anfrage_EA00005.xml" And whe I'm publishing the report, the window with "Select Resources to publish" is just skipped(I find it, when I go Back a step with the publishing wizard) but the xml_url param ist still in the report. I can change the param, and the changes are not lost after publishing to the server :). Do you use groovy or javascript? I can not use javascript, there is a bug report posted: http://community.jaspersoft.com/jaspersoft-studio/issues/3305. But groovy is also ok :). Do you have your JSON Adapter now in use ? :) Have a nice day, Marius Link to comment Share on other sites More sharing options...
vote4me Posted December 11, 2013 Share Posted December 11, 2013 Yes, I do manually insert the XML_URL parameter using JS Studio on a Mac (which may explain the skipping of the Select Resources page). I'm not using either Groovy or Javascript as i'm learning JR... Which also explains why I don't have my JSON adapter yet. I got pulled away onto another project. I'll be back on it in the new year. Perhaps there will be another brave soul to make it easier. Thanks, and happy holidays! Stephen... Link to comment Share on other sites More sharing options...
manojshishodia Posted July 23, 2014 Share Posted July 23, 2014 How can we change GET request to the source form XML_URL to post request. We might get a large xml from the source. I guess for that it will be good if we call source api with POST. Link to comment Share on other sites More sharing options...
vote4me Posted July 25, 2014 Share Posted July 25, 2014 Manojshishodia, this is an educated guess, but to change the request from POST to GET, you would have to write a custom data source and use another parameter. The XML_URL is part of the RemoteXmlDataAdapterService class (http://jasperreports.sourceforge.net/api/net/sf/jasperreports/data/xml/RemoteXmlDataAdapterService.html). Link to comment Share on other sites More sharing options...
mihir_3 Posted September 4, 2015 Share Posted September 4, 2015 Guys, We have a requirement to populate jasper report with remote XML data source. we are using latest s/w version- jaspersoft studio 6.1.0, jasperreprt server 6.1.0. Problem is, we are unable to send user input to data source as parameter. In latest, XML document data adapter we can create the GET/POST parameter but we don't know how to populate parameters value with user input. Any thoughts on this? Thanks -Mihir Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now