运行 Jasper 服务器的 jrxlm 报告

Running jrxlm report with Jasper Server

我已经通过 iReport 创建了 jrxml 报告。然后我将 运行 它与 JasperServer 一起使用,它工作得很好。我已经通过这个 URL:

生成了 pdf 报告
http://localhost:8081/jasperserver/flow.html/flowFile/my_report.pdf

它运行良好,但当我尝试刷新页面时出现此错误:

An id is required to lookup a FlowDefinition

此外,当我尝试在 JasperServer 客户端应用程序中调用此 REST 服务时,出现此错误:

com.sun.jersey.api.client.UniformInterfaceException: Client response status: 500

这是 Java 调用 REST 服务的客户端应用程序:

public final static String serverUrl = "http://localhost:8081/jasperserver/flow.html/flowFile/my_report.xls";
public final static String serverUser = "jasperadmin";
public final static String serverPassword = "jasperadmin";

static File outPutDir= new File(System.getProperty("java.io.tmpdir"));

public static void main(String[] args) {
    try {
        Report report = new Report();
        report.setUrl("/reports/samples/Employees");
        report.setOutputFolder(outPutDir.getAbsolutePath());
        JasperserverRestClient client = JasperserverRestClient.getInstance(serverUrl, serverUser, serverPassword);
        File reportFile  = client.getReportAsFile(report);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

flowId

调用flow.html时,您必须提供一个动作,将其放入flowId。 JasperServer 正在使用 flow.html 提供一个可以通过 URL 访问的接口。例如,如果调用报告,这将是:

_flowId=viewReportFlow

还必须提供报告和参数。因此,考虑到这一点,URL 可能如下所示:

http://localhost:8081/jasperserver/flow.html?_flowId=viewReportFlow&reportUnit=/reports/samples/Employees&j_username=the_user&j_password=secret&output=pdf

服务器错误

连接服务器时,使用这个URL

http://localhost:8081/jasperserver/flow.html/flowFile/my_report.xls

这是不是 JasperserverRestClient 使用的服务器URL。服务器 URL 应如下所示:

http://localhost:8081/jasperserver

注意: flow.html 用于在不登录 UI 的情况下访问 JasperServer。它不是您应该放置报告的应用程序路径。