Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Consuming WCF service from Script task in SSIS
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

23 Posts

Posted - 11/14/2012 :  22:46:12  Show Profile  Reply with Quote
I have a WCF service that is consumed in a web page (aspx page) and is working fine. I want to consume the same WCF service from the script task in my SSIS package. The web method takes three arguments MID, OID and DP and generates a file and returns the page count of the file. I need to save the page count in a variable and then update a record in my table using this page count and DP value that I passed in. I created a service reference for the WCF service in the script task. I used the code from the app.config file and aspx page and embedded it in a script task in my SSIS package. But I get the following run time error:

Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://myServer/MyOrder.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.

If I browse to http://myServer/MyOrder.svc I get the Web service page with a link to wsdl and sample code.

Please suggest what needs to be fixed.

Script task code:

using System;
using System.Data;
using System.Windows.Forms;
using Microsoft.SqlServer.Dts.Runtime;
using ST_9f2fs5ab3ed0457f98101cc5605326ac.csproj.MyOrderService;
using System.ServiceModel;

namespace ST_9f2fs5ab3ed0457f98101cc5605326ac.csproj
    [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
    public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase

        #region VSTA generated code
        enum ScriptResults
            Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
            Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure



        public void Main()
            // TODO: Add your code here                        
            int MID = 135443; int OID = 25;
            string DP = "MyFile.pdf";
            EndpointAddress endpointAddress = new EndpointAddress("http://MyServer/MyOrder.svc");
            BasicHttpBinding serviceBinding = new BasicHttpBinding();
            serviceBinding.Name = "bindingMy_IMyOrders"; 
            serviceBinding.CloseTimeout = new TimeSpan(00, 01, 00);
            serviceBinding.MaxBufferPoolSize = 524288;
            serviceBinding.MaxReceivedMessageSize = 2147483647;
            serviceBinding.ReaderQuotas.MaxStringContentLength = 2147483647;
            serviceBinding.ReaderQuotas.MaxArrayLength = 2147483647;
            serviceBinding.ReaderQuotas.MaxBytesPerRead = 4096;

            serviceBinding.ReceiveTimeout = new TimeSpan(0, 0, 120);
            MyOrdersClient myClient = new MyOrdersClient(serviceBinding, endpointAddress);

            int result = myClient.SaveMyFile(MID, OID, DP);

            Dts.TaskResult = (int)ScriptResults.Success;

Thanks for helping.

Edited by - learnsql123 on 11/15/2012 00:05:22

Starting Member

23 Posts

Posted - 11/15/2012 :  15:57:07  Show Profile  Reply with Quote
Is it a domain issue. The web page that is succesfully consuming it is hosted on the same IIS as the WCF service, but my SSIS package is on a different server.

If so, what is the solution?

Go to Top of Page

Starting Member

1 Posts

Posted - 10/03/2013 :  15:06:39  Show Profile  Reply with Quote
Did you solve this problem? I saw the similar issue in my application now. Hope I can get solution from you.

Thanks in advance.
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000