Aug 22, 2013

Server was unable to process request. ---> Object reference not set to an instance of an object.detail: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Object reference not set to an instance of an object. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

When I was calling SSRS report in sql server 2005. I get error message something like this:

Server was unable to process request. ---> Object reference not set to an instance of an object.detail: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Object reference not set to an instance of an object. at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

Then I debugged my code and found I was passing report parameters incorrectly. For example:

Dim strArr() As String
Dim vcReportParamter As String = "ID=5"

strArr = vcReportParamter.ToString.Split(";")
Dim objParams(strArr.Length + 1) As MYReport.ParameterValue

For count = 0 To strArr.Length - 1

If strArr(count) <> String.Empty Then

Dim objParam As New MYReport.ParameterValue
Dim strTempArr() As String

strTempArr = strArr(count).Split("=")
objParam.Name = strTempArr(0).Trim
objParam.Value = strTempArr(1).Trim

objParams(count) = objParam

End If

Next

Mistake was here: 

Dim objParams(strArr.Length + 1) As MYReport.ParameterValue
That is size of objParams more than actual numbers of parameter.

So I changed my code to :
Dim objParams(strArr.Length - 1) As MYReport.ParameterValue

which fixed my issue :)


If you get same error but due to some other reason put a comment. 

No comments:

Post a Comment