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

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Consuming WCF service from Script task in SSIS

Author  Topic 

learnsql123
Starting Member

23 Posts

Posted - 2012-11-14 : 22:46:12
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:
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
};

#endregion



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);
MessageBox.Show(result.ToString());

Dts.TaskResult = (int)ScriptResults.Success;
}
}
}




Thanks for helping.

learnsql123
Starting Member

23 Posts

Posted - 2012-11-15 : 15:57:07
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?

Thanks.
Go to Top of Page

yzhe
Starting Member

1 Post

Posted - 2013-10-03 : 15:06:39
Hi,
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
   

- Advertisement -