首页 > 代码库 > SSIS Package to Call Web Service

SSIS Package to Call Web Service

原文 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.

WebService 1

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.

1Imports System.Web.Services
2Imports System.Web.Services.Protocols
3Imports 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://www.mamicode.com/http://tempuri.org/">http://tempuri.org/</a>")> _
8<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
9<ToolboxItem(False)> _
10Public Class Service1
11    Inherits System.Web.Services.WebService
12    <WebMethod()> _
13    Public Function MyHelloWorld(ByVal name) As 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 
22End 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”.

WebService 2

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.

WebService 4

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

WebService 8

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.

WebService 5

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 .

WebService 6

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

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

WebService 7

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

 

SSIS Package to Call Web Service