我编写了一个 java 代理来从 ssrs 2008 获取深入报告。如果我通过报告服务器 url 访问它,它工作得非常好,但是在我的 java spring 应用程序中,它失去了功能。例如,我有一个向下钻取报告,如果我单击加号将其展开,它可以在 ssrs url 中工作,但在我的 jsp 中,呈现的 html 不能,它必须像我使用报告服务器 url 一样工作。这是我的代码示例,请告诉我这是否可能。
public String getReport(String ReportUrl) throws Exception
{
ReportExecutionServiceSoapStub service = getService();
ExecutionInfo info = service.loadReport(ReportUrl, null); //Load report
info.setHasDocumentMap(false);
setExecutionId(service, info.getExecutionID()); //You must set the session id before continuing
String format = "HTML4.0"; //Valid options are HTML4.0, MHTML, EXCEL, CSV, PDF, etc
String deviceInfo = "<DeviceInfo><Toolbar>True</Toolbar></DeviceInfo>"; //Only generate an HTML fragment
ByteArrayHolder result = new ByteArrayHolder();
StringHolder extension = new StringHolder();
StringHolder mimeType = new StringHolder();
StringHolder encoding = new StringHolder();
ArrayOfWarningHolder warnings = new ArrayOfWarningHolder();
ArrayOfStringHolder streamIDs = new ArrayOfStringHolder();
service.render(format, deviceInfo, result, extension, mimeType, encoding, warnings, streamIDs); //Render report to HTML
System.out.println(new String(result.value)); //Prints the report HTML; this could be embedded in a JSP
return new String(result.value);
}
public static void setExecutionId(ReportExecutionServiceSoapStub service, String id) throws SOAPException
{
SOAPHeaderElement sessionHeader = new SOAPHeaderElement("http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices", "ExecutionHeader");
sessionHeader.addChildElement("ExecutionID").addTextNode(id);
service.setHeader(sessionHeader);
}
public static ReportExecutionServiceSoapStub getService() throws Exception{
String endpoint = "http://192.168.69.213/reportserver/ReportExecution2005.asmx";
AuthPolicy.registerAuthScheme(AuthPolicy.NTLM, JCIFS_NTLMScheme.class);
ReportExecutionServiceSoapStub service = (ReportExecutionServiceSoapStub)new ReportExecutionServiceLocator(getEngineConfiguration()).getReportExecutionServiceSoap(new URL(endpoint));
service.setUsername("192.168.69.213\\administrator");
service.setPassword("secret");
return service;
}
public static org.apache.axis.EngineConfiguration getEngineConfiguration()
{
java.lang.StringBuffer sb = new java.lang.StringBuffer();
sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n");
sb.append("<deployment name=\"defaultClientConfig\"\r\n");
sb.append("xmlns=\"http://xml.apache.org/axis/wsdd/\"\r\n");
sb.append("xmlns:java=\"http://xml.apache.org/axis/wsdd/providers/java\">\r\n");
sb.append("<globalConfiguration>\r\n");
sb.append("<parameter name=\"disablePrettyXML\" value=\"true\"/>\r\n");
sb.append("<parameter name=\"enableNamespacePrefixOptimization\" value=\"true\"/>\r\n");
sb.append("</globalConfiguration>\r\n");
sb.append("<transport name=\"http\" pivot=\"java:org.apache.axis.transport.http.CommonsHTTPSender\"/>\r\n");
sb.append("<transport name=\"local\" pivot=\"java:org.apache.axis.transport.local.LocalSender\"/>\r\n");
sb.append("<transport name=\"java\" pivot=\"java:org.apache.axis.transport.java.JavaSender\"/>\r\n");
sb.append("</deployment>\r\n");
return new org.apache.axis.configuration.XMLStringProvider(sb.toString());
}
谢谢,任何帮助将不胜感激。