LaVOZs

The World’s Largest Online Community for Developers

'; java - Calling Jasper Reports Server using XML_URL - LavOzs.Com

I have created a .jrxml file which runs nicely in JasperSoftStudio using a Data Sources Adapter that points to a local XML file, however I am unable to execute the report from JasperReports Server, once the .jrxml file and .xml file are moved to the server.

After uploading the .jrxml file, and trying to run it from JasperReports Server, I get an empty report (as expected)

I then manually placed SampleReport.xml in the root directory of the application (C:\Jaspersoft\jasperreports-server-cp-6.0.1\apache-tomcat\webapps\jasperserver) and then I try and load the report (with the .xml file) by appending

&XML_URL=SampleReport.xml to the URL of the report.

I also tried appending &XML_URL=https://localhost:8080/jasperserver/SampleReport.xml (this URL will correctly display the .xml file as-is if entered by itself)

What am I doing wrong?

I have attempted to follow the instructions in http://community.jaspersoft.com/wiki/remote-xml-datasource but to no avail.

I copied the com.jaspersoft.studio.data_6.0.4.final.jar as instructed, and restarted the Tomcat Server. I also set the following in my .jrxml file

<parameter name="xml_url" class="java.lang.String">
        <defaultValueExpression><![CDATA["http://localhost:8080/simple.xml"]]></defaultValueExpression>
    </parameter>
    <queryString language="xPath">
        <![CDATA[/ROOT/BEAN]]>
    </queryString> 

This is how I solved it.

Step 1: Instead of passing the name of the XML file via the parameter XML_URL, I passed it via the parameter net.sf.jasperreports.xml.source (Thanks to @kraig from How to use xml data source on jasper server)

Step 2: I realized that I need to define any parameters which are passed to the report in Report Server. So I added a new Input control called net.sf.jasperreports.xml.source and then I edited the report, and added this input control to the report. (Thanks to @Ibrahim Apachi in Passing parameters through the url)

Step 3: I set the default value of the net.sf.jasperreports.xml.source parameter in the .jrxml of the report.

<parameter name="net.sf.jasperreports.xml.source" class="java.lang.String">
        <defaultValueExpression><![CDATA["https://www.example.com:8080/jasperserver/DefaultReport.xml"]]></defaultValueExpression>
</parameter>

[This is the default xml source to be used if no other xml source is supplied. If another source is supplied, then it overrides this default value...]

Step 4: I then called the report by appending &net.sf.jasperreports.xml.source=https://www.example.com:8080/jasperserver/SampleReport.xml to the URL of the report in Jasper Server

Related
How do I call one constructor from another in Java?
Run a JasperServer report via PHP and pass over the querystring
Send report to local printer from JasperReports Server through URL
HTTP Request POST.Upload JRXML file via JaspeReports Server
Jasper Reports Pro library for Compile & Generating HTML5 reports
Jasper Reports Server - Random white space under the lines when generating a report