如何解决对WCF

时间:2017-10-24 15:54:02

标签: c# .net sockets wcf ssis

我发现了很多关于这个错误的帖子,但到目前为止我没有运气纠正我的错误。

我们有一个使用NetTcpBinding调用的WCF。我从SSIS包中设置它 - 脚本转换来调用WCF。

我能够从我的本地Visual Studio运行SSIS包,它可以工作。但我将它部署到SSISDB,并运行它,它失败了。在我的故障排除过程中,我正在评论正文,这就是RunForecastViaWCFService被注释掉的原因。一旦我添加了client.Open()/ client.Close(),我就开始收到错误。非常感谢任何帮助。

脚本转换中的编码是:

private IClientChannel CreateClient()
{
    var endpointAddress = new EndpointAddress(this.Variables.ServiceURL);
    var binding = new NetTcpBinding();
    binding.CloseTimeout = TimeSpan.MaxValue;
    binding.OpenTimeout = TimeSpan.MaxValue;
    binding.ReceiveTimeout = TimeSpan.MaxValue;
    binding.SendTimeout = TimeSpan.MaxValue;
    binding.ListenBacklog = 10;
    binding.MaxConnections = 10;

    var factory = new ChannelFactory<Infinity.ManufacturingPlanning.Service.Contracts.ServiceContracts.IForecastService>(binding, endpointAddress);
    var serviceChannel = factory.CreateChannel();
    IClientChannel clientChannel = serviceChannel as IClientChannel;

    return clientChannel;
}

public override void Input0_ProcessInputRow(Input0Buffer Row)
{
    try
    {
        var client = CreateClient();
        client.Open();

        var RunForecast = new Infinity.ManufacturingPlanning.Service.Contracts.ServiceModels.CreateForecastServiceModel
        {
            SellingDaysYear = Row.SellingDaysYear,
            SellingDaysPeriod = Row.SellingDaysPeriod,
            OperationsItemCategoryId = Guid.Parse(Row.OperationsItemCategoryId),
            OperationsItemSubCategoryId = Guid.Parse(Row.OperationsItemSubCategoryId),
        };

        //((Infinity.ManufacturingPlanning.Service.Contracts.ServiceContracts.IForecastService)client).RunForecastViaWCFService(RunForecast);
        client.Close();
    }
    catch (Exception)
    {
        throw;
    }
}

我添加了许多绑定选项,只是尝试了我在其他SO帖子中看到的一些建议。

错误如下:

Run WCF For Long Running Processes:Error:
System.ServiceModel.CommunicationException: The
socket connection was aborted. This could be caused by an
error processing your message or a receive timeout being
exceeded by the remote host, or an underlying network
resource issue. Local socket timeout was
'00:09:59.9580000'. ---> System.IO.IOException: The write
operation failed, see inner exception. --->
System.ServiceModel.CommunicationException: The
socket connection was aborted. This could be caused by an
error processing your message or a receive timeout being
exceeded by the remote host, or an underlying network
resource issue. Local socket timeout was
'00:09:59.9580000'. --->
System.Net.Sockets.SocketException: An existing
connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32
offset, Int32 size, SocketFlags socketFlags)
at
System.ServiceModel.Channels.SocketConnection.Write
(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate,
TimeSpan timeout)
--- End of inner exception stack trace ---
at
System.ServiceModel.Channels.SocketConnection.Write
(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate,
TimeSpan timeout)
at
System.ServiceModel.Channels.BufferedConnection.Write
Now(Byte[] buffer, Int32 offset, Int32 size, TimeSpan
timeout, BufferManager bufferManager)

修改:原始帖子后的其他信息:

最后,我们发现它可以通过从SQL Server代理程序作业运行它,而不是手动执行Integration Services目录下的工作。 (我通常会确保一个软件包可以在创建一个工作之前自行运行它。但是我绝望地只是尝试随机的东西。我很惊讶它有效。)但我仍然想知道是什么/如何差异发生了。我可以通过调用者告诉执行报告,这是由我们设置的运行Sql代理作业的gmsa帐户运行的。

但真正困扰我的是以下内容 从我的本地笔记本电脑,使用以具有sysadmin权限的用户身份登录的SSMS,使用Integration Services目录下的Execute,它将失败。

使用VNC进入“服务器”框,使用以具有sysadmin权限的同一用户身份登录的SSMS,使用“Integration Services目录”下的“执行”,它将通过。

如果作业被执行,上述两种方法都可以使用。我们已经阅读了关于SSMS是否应该甚至安装在服务器本身上的混合评论。所以我们真的想了解哪些权利/权限等影响了我们的测试以获得更好的知识。

0 个答案:

没有答案