Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

A reporting service using SOAP calls passing XML to a Data Extension

, 19 Oct 2005 CPOL
Demostrates how to render a report by passing XML to a data extension via SOAP calls.
RSDataExtensionXml_demo.zip
RSTestApp
CustomDataExtension
CustomDataExtension.csproj.user
Web References
BusinessService
BusinessData.disco
BusinessData.wsdl
Reference.map
Global.asax
RsReportViewer
AwReportViewer.suo
Design
vssver.scc
RsReportViewer.csproj.user
Web References
RS
Reference.map
ReportService.wsdl
RSTestApp.csproj.webinfo
RSTestReports
Northwind.rds
Northwind.udl
Report1.rdl
Report1.rdl.data
RSTest.rptproj.user
RSTestReports.rptproj
RSTestReports.rptproj.user
Sales Order Detail.rdl
Sales Order Detail.rdl.data
Territory Sales Drilldown.rdl
Territory Sales Drilldown.rdl.data
RSTestWS
Global.asax
RSTestWS.csproj.webinfo
temp
Web References
ReportServer
Reference.map
ReportService.wsdl
using System;
using System.Xml;
using System.Diagnostics;
using System.Collections;

using Microsoft.ReportingServices.DataProcessing;

namespace CustomDataExtension
{
	/// <summary>
	/// </summary>
	public class DataSetCommand : IDbCommand 
	{
		private string _commandText;
		private DataSetParameterCollection _parameters = new DataSetParameterCollection();

		/// <summary>
		/// Default Constructor
		/// </summary>
		public DataSetCommand() {}

		/// <summary>
		/// Attempts to cancel the current command
		/// </summary>
		public void Cancel () 
		{
			throw (new NotSupportedException ("Command cancellation is not currently supported"));
		}

		/// <summary>
		/// Gets/sets the current command type
		/// </summary>
		/// <remarks>
		/// Only the Text command type is supported for this extension
		/// </remarks>
		public CommandType CommandType 
		{
			get { return (CommandType.Text); }
			set 
			{
				if (value != CommandType.Text)
					throw (new NotSupportedException ("Only the Text command type is supported for this extension"));
			}
		}

		/// <summary>
		/// Retrieves an interface used to retrieve data and schema information
		/// </summary>
		/// <param name="behavior">The requested behavior</param>
		/// <returns>An interface to a data reader object</returns>
		public IDataReader ExecuteReader(CommandBehavior behavior) 
		{
			XmlDocument doc = new XmlDocument();
			try
			{
				// load the CommandText XML and append dataset parameters
				doc.LoadXml(CommandText);

				// Append all the dataset parameter
				// example: WebMethod contains which web service method to execute.				
				DataSetParameter parameter = null;
				IEnumerator enumerator = _parameters.GetEnumerator();
				while (enumerator.MoveNext())
				{
					parameter = (DataSetParameter) enumerator.Current;
					XmlElement elem = doc.CreateElement(parameter.ParameterName);
					elem.AppendChild(doc.CreateTextNode(parameter.Value.ToString()));
					doc.DocumentElement.AppendChild(elem);
				}
			}
			catch (Exception ex)
			{
				throw new Exception("Invalid Xml command Text: " + CommandText, ex);
			}

			return new DataSetDataReader(doc.InnerXml);
		}

		/// <summary>
		/// Gets/sets the command timeout.
		/// </summary>
		/// <remarks>
		/// A CommandTimeout other than 0 is not supported by this extension.
		/// </remarks>
		public Int32 CommandTimeout 
		{
			get {return (0);}
			set {} //Do nothing
		}

		/// <summary>
		/// Gets/sets the current command text
		/// </summary>
		/// <remarks>
		/// This CommandText will be an XML string containing filter information etc.
		/// </remarks>
			public String CommandText 
			{
				get { return (this._commandText); }
				set { this._commandText = value; }
			}

		/// <summary>
		/// Gets/sets an object that allows action on the transaction
		/// </summary>
		/// <returns>null since we do not support transactions</returns>
		public IDbTransaction Transaction 
		{
			get { return null; }
			set { throw (new NotSupportedException());	}
		}


		IDataParameterCollection IDbCommand.Parameters
		{
			get  { return _parameters; }
		}


		/// <summary>
		/// Creates a new data parameter (not used)
		/// </summary>
		public IDataParameter CreateParameter() 
		{
			return (IDataParameter)(new DataSetParameter()) ;
		}

		/// <summary>
		/// Retreives the current parameters list (not used)
		/// </summary>
		public IDataParameterCollection Parameters 
		{
			get { return _parameters; }
		}

		/// <summary>
		/// Dispose of any held resources
		/// </summary>
		public void Dispose() 
		{
			if (_parameters != null)
			{
				_parameters.Dispose();
			}
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Ken C. Len
Software Developer (Senior) LEN Associates Inc.
United States United States
Years of software consulting and software development using Microsoft development products such as Microsoft Content Management System, SQL Server Reporting Service, ASP.Net C# VB.Net, HTML and javascript web development, Visual Studio add-on development, C++ MFC/ATL and COM+ development, and ActiveX components.

| Advertise | Privacy | Mobile
Web02 | 2.8.141015.1 | Last Updated 19 Oct 2005
Article Copyright 2005 by Ken C. Len
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid