Background
As we know, SSIS (SQL Server Integration Service) is a data migration software used to extract, transform, and load the data. I am not going to explain what SSIS is and what its features are, but yes, this article illustrates the purpose of SSIS with Web Service. It’s all about how SSIS can use Web Service to perform certain operations, like updating the database table based on Service response or process the data, etc.
Not only Web Service but SSIS can consume the following services as well:
- WCF service
- Web API
- Net Core API
These are the different services provided by Microsoft .NET technology. I will explain how to consume these services through SSIS package in my next article.
Let’s say we have one Web Service running in IIS and it exposes the ProcessData() method. It does some business functionality internally and sends the details to a third party service. It provides the reference number to the client. (Refer the below screen.)
More about Web Service
It’s an XML service and runs on HTTP & HTTPS protocol. It accepts the XML request and provides the response in XML format.
Solution
To consume the Web Service into the SSIS package, first, create the SSIS application. You should have SSDT (SQL Service Data Tools) installed on your system. I have used SSDT 2015 in my sample application.
Follow the below steps.
- Create package (package.dtsx) inside the SSIS project.
- Drag the script task from SSIS toolbox on "Package Design" screen (refer the below screen).

- Double click on "Script Task".
- Click on "Edit Script".

- It will open the VstaProjects where you can write the C# custom code.
- Go to the Solution Explorer.

- Right click on Reference.
- Give the Web Service URL and add into the project (refer the below screen).
- Follow the below code. Here, I am passing the transactionID and amount to the ProcessData().
- #region Namespaces
- using System;
- using System.Data;
- using Microsoft.SqlServer.Dts.Runtime;
- using System.Windows.Forms;
- #endregion
- namespace ST_c02ad868b1314c3895bebfedd71e7fbf
- {
- /// <summary>
- /// ScriptMain is the entry point class of the script. Do not change the name, attributes,
- /// or parent of this class.
- /// </summary>
- [Microsoft.SqlServer.Dts.Tasks.ScriptTask.SSISScriptTaskEntryPointAttribute]
- public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
- {
- /// <summary>
- /// This method is called when this script task executes in the control flow.
- /// Before returning from this method, set the value of Dts.TaskResult to indicate success or failure.
- /// To open Help, press F1.
- /// </summary>
- public void Main()
- {
- // the below detail can be pulled from database and send to the service.
- long transactionID = 110011;
- decimal amount = 500.0m;
- ServiceManager.DemoService demoService = new ServiceManager.DemoService();
- try
- {
- var result = demoService.ProcessData(transactionID, amount);
- //based on result or status you can update the required table.
- //TODO
- Dts.TaskResult = (int)ScriptResults.Success;
- }
- catch (Exception ex)
- {
- Dts.TaskResult = (int)ScriptResults.Failure;
- }
- }
- #region ScriptResults declaration
- /// <summary>
- /// This enum provides a convenient shorthand within the scope of this class for setting the
- /// result of the script.
- ///
- /// This code was generated automatically.
- /// </summary>
- enum ScriptResults
- {
- Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
- Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
- };
- #endregion
- }
- }
- When you debug the SSIS package, you get the response from Web Service (refer the below screenshot).

Conclusion
SSIS provides the features by using a script component to consume the Web Service. And, it can be achieved by writing the custom code in SSIS.

sandeep chowdaryPosted Dec 9, 2020, 12:19 AM
Nice article, how can we consume web api if we have credential's for the service?
Ella LevitinPosted Mar 12, 2019, 10:18 AM
Thank you for the article, it is very helpful. My question is, if service is changed and need to update configuration, is it any way to do it in script programmatically?