2016-05-27 102 views
0

我已經通過iReport創建了jrxml報告。然後我用JasperServer運行它,它工作得很好。我有這個URL生成PDF報告:使用Jasper Server運行jrxlm報告

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(); 
    } 
} 
+0

'我得到這個錯誤com.sun.jersey.api.client.UniformInterfaceException:客戶端響應狀態:500' - 你檢查日誌文件嗎? –

回答

2

流ID

當調用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 

Server錯誤

當連接到服務器時,該URL用於

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

這是的服務器URL使用JasperserverRestClient。服務器URL應該是這樣的:

http://localhost:8081/jasperserver 

注:flow.html是訪問的JasperServer,而無需登錄到用戶界面。它是而不是您應該放置報告的應用程序路徑。

+0

感謝tobi6,你幫了我。 –

+0

你能幫助我如何獲得報告休息客戶端的路徑嗎?http://stackoverflow.com/questions/37509433/jasperserver-rest-client-path –

+0

高興地幫助。請考慮接受我的答案(或其他),如果它適合你([如何接受答案](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work)) 。 – tobi6