Pro SQL Server 2012 Reporting Services

(sharon) #1

CHAPTER 7  USING CUSTOM .NET CODE WITH REPORTS


In the sample code for Chapter 7, we have also included a web service that can be called from the
custom code to access the employee pay information. This simulates accessing information from
another system via a web service and is designed to allow you to replace the exported XML file with a call
to a web service. The Employee class included in the sample code already contains a method called
CostPerVisitWS that uses the web service rather than the XML file as its source of data. You can make the
report use the web service instead of the XML file by simply changing the expression from this:

=Pro_SSRS.Employee.CostPerVisitXML(Fields!EmployeeID.Value,
Fields!ChargeServiceStartDate.Value)* sum(Fields!Visit_Count.Value)

to the following:

=Pro_SSRS.Employee.CostPerVisitWS(Fields!EmployeeID.Value,
Fields!ChargeServiceStartDate.Value)* sum(Fields!Visit_Count.Value)

To try this, just open the sample solution for this chapter, and edit the expression in the
Employee_Cost field in the EmployeeServiceCost.rdl file. To try the Employee Web Service, you also must
make sure the Web service is running when you debug the report in Visual Studio or that it is published
and running on your test machine if you have the report deployed to the server. Let’s go through the
code in our Employee class that calls the web service and show how the process works in our report.
Open the EmployeeServiceCost report in design mode and go down to the employee estimated cost
column in your table. Let’s edit the expression using the previous example we provided for use with the
web service. Once you edit the expression to use the web service call, it should look like Figure 7-14.
Free download pdf