使用Java呈现SSRS报告

时间:2016-04-30 18:57:04

标签: java ssrs-2012

我正在研究一个应该用Java呈现SSRS报告的项目。

以下是我遵循的程序。

  1. 已安装的Eclipse
  2. 创建一个java项目通过设置Execution Environment Java SE 1.8
  3. 使用wsimport创建代理
  4. wsimport image

    1. 添加了生成代理的引用
    2. added classed

      1. 编写此代码

        import javax.xml.ws.BindingProvider;
        import javax.xml.ws.Holder; 
        
        import  com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfString;
        import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ArrayOfWarning;
        import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionHeader;
        import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ExecutionInfo;
        import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportExecutionService;
        import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.ReportExecutionServiceSoap;
        
        
          public class Render {
        
         static {
                  java.net.Authenticator.setDefault(new java.net.Authenticator()   {
            @Override
            protected java.net.PasswordAuthentication getPasswordAuthentication() {
                return new java.net.PasswordAuthentication("username", "pwd".toCharArray());
            }
        });
        }
        
        public static void main(String[] args) {
        
        String reportPath = "/Reporting/Customers" ;
        String format = "HTML4.0";
        String historyID = null;
        String devInfo = "<DeviceInfo><Toolbar>False</Toolbar><HTMLFragment>True</HTMLFragment></DeviceInfo>";
        String executionID = null;
        Holder<String> extension = null;
        Holder<String> mimeType = null;
        Holder<String> encoding = null;
        Holder<ArrayOfWarning> warnings = null;
        Holder<ArrayOfString> streamIDs = null;
        Holder<byte[]> result = new Holder<byte[]>(); 
        
        ReportExecutionService res = new ReportExecutionService();
        ReportExecutionServiceSoap ress = res.getReportExecutionServiceSoap(); 
        
        BindingProvider bp = (BindingProvider)ress; 
        
        bp.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);  
        
        ExecutionInfo execInfo = new ExecutionInfo();  
        execInfo = ress.loadReport(reportPath, historyID); 
        executionID = execInfo.getExecutionID();       
        bp.getRequestContext().put("sessionID", executionID); 
        
        ExecutionHeader eh = new ExecutionHeader();
        eh.setExecutionID(executionID); 
        System.out.println(executionID);
        ress.render(format, devInfo, result, extension, mimeType, encoding, warnings, streamIDs);
        
        String resultString = new String(result.value); 
        
        }
        
        }
        
      2. 当我运行此代码时,我收到以下错误。

             Exception in thread "main"    com.sun.xml.internal.ws.fault.ServerSOAPFaultException: Client received SOAP Fault from server: The session identifier is missing. A session identifier is required for this operation.  ---> Microsoft.ReportingServices.Diagnostics.Utilities.MissingSessionIdException: The session identifier is missing. A session identifier is required for this operation.  Please see the server log to find more detail regarding exact cause of the failure.
        at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
        at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
        at com.sun.xml.internal.ws.client.sei.StubHandler.readResponse(Unknown Source)
        at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(Unknown Source)
        at com.sun.xml.internal.ws.db.DatabindingImpl.deserializeResponse(Unknown Source)
        at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
        at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
        at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
        at com.sun.proxy.$Proxy35.render(Unknown Source)
        at Render.main(Render.java:50)
        

        我是java新手,我错过了什么?我已经设置了会话ID。

        任何帮助表示赞赏。

        提前致谢。

0 个答案:

没有答案