Arvixe and Reporting Services Using Web Service (Part 7 of 7)

Well this is my final article on Arvixe and Microsoft Reporting Services (maybe). If you have been following my articles you know that we have worked up to this last article. To say that “I saved the best for last” is probably not far from reality. Consuming a Reporting Service Report using the Report Viewer as in this article is fairly simple to do but I believe the real integration with your web site comes from consuming the web service portion of Reporting Services. This provides you with complete control and integration with your web application. You can also use Reporting Services to return an Excel Document without the user knowing that you are using SSRS to do the heavy lifting. There are also other reasons to do this which I will discuss as we build this example.

To be honest I have written a prior example on how to do this here, but since I am have used an “Arvixe Account” for my other articles, I thought I would refresh my prior article (many months ago) with this “Arvixe account” along with a few new things. As I have used in the prior examples we are assuming that ARVIXE sends you something like this after you have subscribed to SSRS through ARVIXE.


Let’s get started:

Step 1: Launch VS2012 (or like version) and Create a blank web Application.

Step 2: Add new form and call it ‘ShowReport.aspx’. When you’re done your project should look similar to this (Figure 1)

Figure1Figure 1

Step 3: Add Service Reference and click on Advanced–> (Figure 2)

Figure 2

 Step 4: Click on Add Web Reference (Figure 3)Figure3

Figure 3

Step 5: Enter URL (Using the SSRS Information that Arvixe sent you would enter.
””  (without quotes) and press the little icon to the right.  If everything works you should see something like Figure 4 (where it finds 1 Service).  If you do then click on Add Reference.


Figure 4

The hard part is done…Now go to your code behind page on the page created in step 2 and add the following two sections;  (Pay Attention to the parameters toward the top part of the code.)

Section 1: Add to the top of the page

[code language=”vb”]
Imports System
Imports System.Net
Imports System.Web.Configuration

Section 2: Add to the Page Load section

[code language=”VB”]
Dim rs As ReportExecutionService = New ReportExecutionService

Dim reportPath As String = "/ReportName"
rs.Url = ""
‘Add a NetworkCredential instance to CredentialCache.
rs.Credentials = New NetworkCredential("angler2be_report", "1Password1", "")

Dim execInfo As ExecutionInfo = New ExecutionInfo()
Dim execHeader As ExecutionHeader = New ExecutionHeader()

Dim historyID As String = Nothing

Dim extension As String = ""
Dim mimeType As String = ""
Dim encoding As String = ""
Dim warning As Warning() = Nothing
Dim streamID As String() = Nothing
Dim result() As Byte = Nothing

‘Dim ReportParams(2) As ParameterValue
‘ReportParams(0) = New ParameterValue()
‘ReportParams(0).Name = "ParameterName"
‘ReportParams(0).Value = "ParameterValue"

‘ReportParams(1) = New ParameterValue()
‘ReportParams(1).Name = "ParameterName2"
‘ReportParams(1).Value = "ParameterValue2"

‘ReportParams(2) = New ParameterValue()
‘ReportParams(2).Name = "ParameterName3"
‘ReportParams(2).Value = "ParameterValue3"

Dim ReportHistoryParameters As ParameterValue() = Nothing

Dim devInfo As String = "False"

rs.ExecutionHeaderValue = execHeader
execInfo = rs.LoadReport(reportPath, historyID)
‘rs.SetExecutionParameters(ReportParams, "en-us")
result = rs.Render("PDF", devInfo, extension, mimeType, encoding, warning, streamID)

Response.AppendHeader("content-length", result.Length.ToString())
Response.ContentType = "application/pdf"

End Sub

NOTE 1: I have commented out the parameters. If you have any you can add them here.
NOTE 2: Also keep in mind you can use this on other events and export to other formats. I just wanted it to be very simple so that you know that there really isn’t any then special happening.

That’s it. If you have problems with this then read this article to make sure that SSRS has been set up properly.

Looking for quality web hosting? Look no further than Arvixe Web Hosting!

Tags: , , , , , , , , , , , | Posted under Programming/Coding | RSS 2.0

Author Spotlight

David Bauernschmidt

I live in the historical triangle of Virginia where I am married with two daughters. I have spent over 13 years working for a Fortune 500 company in the computer area. I started in VB 6.0 and by the time I ended my employment I was supervising a development team where we built many web applications. When my first daughter was born I wanted to spend more time with her so I left and became a programmer analyst for local government as well as launch my own company. Since then I have grown James River Webs into a profitable web design and application company helping small businesses create a big presence on the internet. As an employee I have created web application used by citizens and other companies. I enjoy fly fishing, and spending time with my family. I also enjoy learning new approaches and development tools when it comes to developing applications.

Leave a Reply

Your email address will not be published. Required fields are marked *