Monday, March 26, 2012

Report Viewer to Get Data from RS Deployed on separate Network.

Hi,

I am using Reporting Services in the following way. The application implements a three tier Architecture viz Web Server, Application Server and Database Server. Reporting Services 2005 is installed on the Database Server.

The application uses ReportViewer Control which is part of an ASPX page deployed on the Web Server. For ReportViewer Control to fetch data from Reporting Services using RS API, we have to set ReportServerUrl and Report Path. In this scenario, the web server cannot communicate to the database server directly. The web server is in the DMZ and it can only communicate with the Application Server which is in a separate Network.

How can I use Report Viewer Control to fetch data from Reporting Services which is on the Database Server.

Thanks & Regards,

Rajiv

I am afraid you won't like the answer but the Report Viewer control assumes a direct connection to the Report Server web service. It looks like in your situation, you need to install RS on the application server. A split deployment scenario is also an option (RS middle tier on the application server, while the catalog is on the database server) but you will need two licenses. Finally, in case you wan't to get innovative, try implementing an HttpHandler on the application server that would intercept SOAP and URL requests generated by the ReportViewer and forward them to the database server. I haven't done this but it should be possible. If you decide to try the last option, please post your findings here.|||

Hi,

Thanks for your reply. I am working on the approach that you have suggested. I have created an HttpHandler which is deployed as an Application Gateway on the Application Server. In the process request method of HttpHandler I am using HttpContext to get the current request and create a new request to the reporting server.

I am using windows XP, IIS 5.1. , Microsoft Visual Studio 2005 and Asp.net 2.0.

Scenario : Request an ASP.NET Page from the Webserver... which in turn makes a new request using HttpHandler which invokes Reporting Server.

"abc.aspx" page includes report viewer control. This page is deployed on the web server. The following properties are set for ReportViewer Control.

ReportVwrObj.ServerReport.ReportServerUrl = HTTPHandlerURL;

ReportVwrObj.ServerReport.ReportPath = ConfigurationManager.AppSettings["WebReportResults"].ToString ( ); //report file name and path.

Using Http Handler : I was able to sucessfully create a new request once i get the request from web server........However, I came across few issues related to Response.

Below is the sample code implemented in the ProcessRequest Method of HttpHandler.

public void ProcessRequest ( HttpContext context )

{

context.Response.ContentType = "text/plain";

//Url Request

RequestURL = "http://MahineName/reportserver";

///create the web request to get the remote stream

HttpWebRequest objRequest = ( HttpWebRequest ) WebRequest.Create ( RequestURL );

//objRequest.Credentials = CredentialCache.DefaultNetworkCredentials;

NetworkCredential nt = new NetworkCredential ( "Username", "Password", "Domain." );

objRequest.Credentials = nt;

objRequest.KeepAlive = false;

boolException = false;//clear exception

objResponse = ( HttpWebResponse ) objRequest.GetResponse ( );

if ( ( objResponse.ContentType.ToLower ( ).IndexOf ( "html" ) >= 0 ) || ( objResponse.ContentType.ToLower ( ).IndexOf ( "javascript" ) >= 0 )

||( objResponse.ContentType.ToLower ( ).IndexOf ( "xml" ) >= 0 ) )

{

//this objResponse is HTML Content, so we must parse it

StreamReader objReadStream = new StreamReader ( objReceiveStream, Encoding.Default );

//Uri test = new Uri(strRemoteUrl);

strContent = "";

strContent = objReadStream.ReadToEnd ( );

context.Response.ContentType = objResponse.ContentType;

context.Response.Flush ( );

context.Response.Write ( strContent );

///close streams

objReadStream.Close ( );

objResponse.Close ( );

}

context.Response.End ( );

}

In the above code, I have created a new httpwebrequest to forward the request to the reporting server. For the newly created request i get the response and flush it . I came across the below error while following this approach.

  • Response is not well-formed XML.
  • Data at the root level is invalid. Line 1, position 1.
  • Any Clue on this ?

    |||Use a listener such as tcpTrace or SoapUtil to capture the request from the HttpHandler by redirecting to http://MahineName:8080/reportserver. It looks like the XML got distorted or something.
  • No comments:

    Post a Comment