How to pass XML_URL to a report with a remote XML data source over a web service


Hello Community,

after reading the tutorials below:

I 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.0

Thank you, Marius



mariuss's picture
Joined: Aug 11 2013 - 2:33pm
Last seen: 7 years 6 months ago

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 here

2.  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["" + $P{rss_feed}]]></defaultValueExpression

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/...?rss_feed=FOO

5. 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.

vote4me - 7 years 8 months ago

1 Answer:


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} : ""]]></defaultValueExpression>
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.
vote4me's picture
Joined: Nov 15 2013 - 10:45am
Last seen: 6 years 11 months ago

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:
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:
Maybe it is better to open a new thread for that.

So many thanks again :)

mariuss - 7 years 8 months ago

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.


vote4me - 7 years 8 months ago

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 And you can take a look at the Chapter 5(Custom Data Sources) of JasperServer Ultimate Guide:
And here is another thread about data adapter:
I hope this can help you a little bit :)


mariuss - 7 years 8 months ago
show 6 more...

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:

vote4me - 7 years 8 months ago

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:
<parameter name="XML_URL" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA[$P{XML_URL} ? $P{XML_URL} :"http://server:8080/nav/xml/test/Anfrage_EA00005.xml"]]></defaultValueExp...
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: But groovy is also ok :).
Do you have your JSON Adapter now in use ? :)

Have a nice day, Marius

mariuss - 7 years 7 months ago

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!


vote4me - 7 years 7 months ago

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.

manojshishodia - 7 years 1 week ago

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 (

vote4me - 7 years 6 days ago

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?

mihir_3 - 5 years 11 months ago