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.