banner



How Could You Traditionally Consume An Asmx Web Service From Your Application

I recently worked on a project that used web services to feed information to the SSRS reports that were created for the various business organization segments at this particular organization. Stemming from that projection, this blog post will nowadays how to create a elementary web service that returns a serialized dataset and a simple SSRS report that uses (consumes) this web service to feed data to the report.

A spider web service provides data equally a service over the Cyberspace or inside an internal network. Standard Web Services use the SOAP protocol which defines the advice and structure of letters, and XML is the default information format. Web services are designed to allow applications congenital using different technologies to communicate with each other without issues. Examples of web services include Weather.com and the manner the site provides weather information that other sites can use, or UPS.com providing a method to request shipping quotes or tracking of packages.

Building a Simple Web Service

In the following example, I am going to detail how to build a simple web service which volition return a single data set (or list) of information about a fictitious apartment building. I will likewise prove how to create a simple SSRS report which consumes this dataset and produces a table listing of this information. For this example, I am using Visual Studio 2013 with the BIDS add together-on for 2014. I have written the web service example in C# and I am using .Internet Framework 3.0 Web Service engineering for the web service itself.

The Web Service

1. Open Visual Studio and create a simple web service project equally seen beneath.  In this example, I accept given the web service a name of 'AptWebSVC'.

AptWebSVC

Below is what the code in the AptWebSVC.Asmx.cs file will look like when it is first created:

NamespaceAptWebSVC-768x325

2. Rename the Grade 'Service1' to 'AptWebSVC'.

public class AptWebSVC : System.Web.Services.WebService

3. Rename the file chosen Service1.asmx to AptWebSVC.asmx in the Solution Explorer window.

Solution Explorer

4. Right click the 'AptWebSVC.asmx' file in the Solution Explorer window and select 'View Markup' in order to edit the Class designation on the page so that it looks similar the following:

WebService Language

5. Alter the lawmaking for the web service to provide the dataset that you wish to return. For the purposes of this demonstration, I have simply provided one method that returns a list of hard-coded values representing a fictitious flat building and some basic information virtually each apartment. Below is the sample code that is in this solution. Note that at the top I have defined a class which will represent the data that is going to exist returned by the spider web service method called 'GetAllUnits()'.

Code Part1

6. Build and publish this web service to IIS on the web server of your choosing. Non that for this blog, I assumed that the reader knows how to publish and install a spider web service nether Microsoft'due south IIS server.

7. Test the web service and make certain that it returns a dataset that looks similar the following output:

Detect that the information returned is surrounded by XML tags and has been converted to ASCII. This is important to understand when manipulating or using the data in the SSRS report designer linguistic communication (RDL). For instance, if you are passing a field of type 'Decimal' or 'Double' from the web service to the SSRS report, y'all will need to convert this ASCII field from the web service to a double or decimal field inside the written report when using it for calculation purposes.

Code

Designing the SSRS Report

1. Create a new Visual Studio project for Reporting Services like the post-obit:

Apartment Report

– In this instance, I take named the study 'ApartmentReport'.

2. Correct click on 'Reports' in the Solution Explorer and add a new report:

Report

– I have named this report 'ApartmentReport.rdl.

3. On the left of the screen, right click on 'DataSources' and select 'Add together Data Source':

Data Sources

four. In the dialog box that is displayed, requite the data source a name (I named mine ApartmentDataSource). Select the 'Embedded Connection' radio button, Select 'XML' equally the Blazon and enter the HTTP address of the spider web service that was deployed to IIS in the earlier step. Mine happens to be http://localhost:3010/AptWebSvc.asmx.

Data Source Properties

5. On the 'Credentials' tab of this dialog, choose the credential method that makes sense for your installation.

vi. Correct click on the 'Datasets' field on the Report Information view and cull 'Add Dataset':

Report Data

seven. In the dialog box for the new dataset, give the dataset a proper noun (I named mine 'ApartmentDataSet'. Select the 'Use a dataset embedded in my written report' radio push. Select the 'ApartmentDataSource' from the DataSource driblet downward and and so fill in the Query text with what is shown below.

Data Set Properties

– Note that the Method proper noun (GetAllUnits()) in the 'Query' text is the aforementioned proper noun equally nosotros coded in our web service.

8. Click OK.

9. Add together a tabular array to the report design surface and fill up in the header columns similar below:

Header Columns

10. Correct click the top left corner of the table and select 'Tablix Properties':

Tablix Properties

11. Under the 'Full general' section of this dialog, give the table a proper noun and then select the 'ApartmentDataSet' from the driblet down box:

Change Name

12. In each of the columns for the table on the study, right click on the column under the respective header and select 'Expression':

Expression

13. Choose the correct dataset field to be placed into the text box for each column:

Fields Expression

14. Preview the study and the output should look like the following:

Output

As you tin can see, adding a web service to a report which has been designed using SSRS is simple and extremely flexible. Since the spider web service handles all of the formatting and gathering of the data for each web method which returns data, complex logic can be implemented in the web service to perform tasks that might otherwise be difficult, if not incommunicable to do using SQL at run time. In addition, you lot are non limited to merely one information method in the spider web service. Each dataset required for a report tin call a different method if needed to format the data in the manner that is desired for the report. While not covered in this tutorial, information technology is also easy to pass parameters into the web service from the report to allow for data filtering using the criteria passed in to the web service method.

As you tin can run into, following these few steps, information technology's relatively easy to create a simple web service that returns a serialized dataset and a unproblematic SSRS study that uses spider web service to feed data to the report.

How Could You Traditionally Consume An Asmx Web Service From Your Application,

Source: https://www.teamscs.com/2015/12/consuming-a-web-service-in-a-ssrs-report/

Posted by: youngyeard2001.blogspot.com

0 Response to "How Could You Traditionally Consume An Asmx Web Service From Your Application"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel