SSIS Package to Call Web Service

时间:2024-08-13 20:37:50

原文 SSIS Package to Call Web Service

SSIS Package to Call Web Service.

You can Call WebService from SSIS package and transfers your data.

First of all you have to create web service with function as  you needed to call.

Step1 : Go To Microsoft Visual Studio –> New –> WebSite –> ASP.Net WebService and provide you web service name.

SSIS Package to Call Web Service

Step2 : Paste below code to your Service1.asmx.vb file.

I have created new function “MyHelloWorld” with parameter name in which i am passing a string to write in a destination file.

1 Imports System.Web.Services
2 Imports System.Web.Services.Protocols
3 Imports System.ComponentModel
4  
5 ' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
6 ' <System.Web.Script.Services.ScriptService()> _
7 <System.Web.Services.WebService(Namespace:="<a href="http://tempuri.org/">http://tempuri.org/</a>")> _
8 <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
9 <ToolboxItem(False)> _
10 Public Class Service1
11     Inherits System.Web.Services.WebService
12     <WebMethod()> _
13     Public Function MyHelloWorld(ByVal nameAs String
14         Dim FILE_NAME As String = "E:\WebServiceTextFromService.txt"
15         Dim objWriter As New System.IO.StreamWriter(FILE_NAME, True)
16  
17         objWriter.Write(name)
18         objWriter.Close()
19         Return "Process Completed."
20     End Function
21  
22 End Class

Step3 : Now Create New SSIS Package with your desired name.

Drag Weservice Task to Control Flow.

Create one variable “Result” with datatype string and value “I am writting this content to file by web service task”.

SSIS Package to Call Web Service

Step4 : Create one http connection manager. i am using 61508 port number for my local web service so my Server URL :http://localhost:61508.

This port number is assigned by default, you can change port number from web service property.

SSIS Package to Call Web Service

Step5 : Create one file connection to write output result to local path.

SSIS Package to Call Web Service

Step6 :  Right click on Web Service Task –> Edit.

On General Tab Select HTTP Connection Manger which you have created on Step4.

Select your WSDL file path to WSDLFile field.

SSIS Package to Call Web Service

Step7 : Select Input path of Web Service Task Editor.

Select your service name in Service and Method “MyHelloWorld” which you have created on Step2.

After selecting Method, Parameter field enables automatically.

Click on Variable checkbox and select User::Result in value .

SSIS Package to Call Web Service

Step8 : Select OutPut tab on left pane on Web Service Task Editor.

Select Flat File Connection “WebServiceText.txt” in File Field.

SSIS Package to Call Web Service

Step9 : After completing this build and run the project and you will get file will be created on “D:\WebServiceText.txt”

with the content “I am writting this content to file by web service task”.

Regards,

Nirav Gajjar