SQL Server Developer Center > SQL Server Forums > SQL Server Reporting Services > How to pass SessionId from java webservice client to ReportExecutionService
Ask a questionAsk a question
 

Proposed AnswerHow to pass SessionId from java webservice client to ReportExecutionService

  • Thursday, May 01, 2008 2:35 PMSrikodati Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

     

    I trying to execute the render method in the ReportExecutionService using AXIS java client.

    I call the loadReport which executed succesfully and I got the ExecutionId.

    But I am not sure where to set this ID.

    When I call the render method I am getting

    The session identifier is missing. A session identifier is required for this operation.  ---> The session identifier is missing. A session identifier is required for this operation.

     

    Any help is appreciated

     

    Regards,

    Sri

All Replies

  • Friday, October 02, 2009 5:56 AMRaj Goraya Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Proposed AnswerHas Code
    package client;
    
    import java.io.FileOutputStream;
    import java.io.OutputStream;
    
    import javax.xml.rpc.holders.ByteArrayHolder;
    import javax.xml.rpc.holders.StringHolder;
    import javax.xml.soap.SOAPElement;
    
    import org.apache.axis.client.Call;
    import org.apache.axis.message.SOAPHeaderElement;
    import org.apache.log4j.Logger;
    
    import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.*;
    import com.microsoft.schemas.sqlserver._2005._06._30.reporting.reportingservices.holders.*;
    
    public class GenerateReport {
    
    
    	public void GenerateReport(String reportName, OutputStream ouptutStream) throws Exception {
    		ReportExecutionServiceLocator exLoc = new ReportExecutionServiceLocator();
    		ReportExecutionServiceSoap rs 
    			= exLoc.getReportExecutionServiceSoap(
    					new java.net.URL("http://yourserver:80/ReportServer/ReportExecution2005.asmx")
    				);
    		org.apache.axis.client.Stub clientStub = (org.apache.axis.client.Stub) rs;
    
    		clientStub._setProperty(Call.USERNAME_PROPERTY, "goraya");
    		clientStub._setProperty(Call.PASSWORD_PROPERTY, "goraya");
    		ExecutionInfo execInfo = new ExecutionInfo();
    		execInfo = rs.loadReport(reportName, null);
    
    		SOAPHeaderElement sessionHeader = new SOAPHeaderElement(
    				"http://schemas.microsoft.com/sqlserver/2005/06/30/reporting/reportingservices",
    				"ExecutionHeader");
    		SOAPElement addChildElement = sessionHeader.addChildElement("ExecutionID");
    		addChildElement.addTextNode(execInfo.getExecutionID());
    		clientStub.setHeader(sessionHeader);
    
    		String format = "PDF";
    		String devInfo = "<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
    		ByteArrayHolder result = new ByteArrayHolder();
    		StringHolder extension = new StringHolder();
    		StringHolder mimeType = new StringHolder();
    		StringHolder encoding = new StringHolder();
    		ArrayOfWarningHolder warnings = new ArrayOfWarningHolder();
    		ArrayOfStringHolder streamIDs = new ArrayOfStringHolder();
    		rs.render(format, devInfo, result, extension, mimeType, encoding, warnings, streamIDs);
    		ouptutStream.write(result.value);
    	}
    
    	public static void main(String args[]) {
    		String path = "/Reports/Test Report";
    		try {
    			FileOutputStream o = new FileOutputStream("C:\\TEMP\\TestReport.pdf");
    			new GenerateReport().GenerateReport(path, o);
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    	}
    
    }
    
    
    • Proposed As Answer byRaj Goraya Friday, October 02, 2009 6:18 AM
    •