c# - 在 SSIS 中使用 Web 服务给出 'Mismatch between the processor architecture'

标签 c# web-services ssis script-component

我尝试按照下面的教程在 SSIS 的脚本组件中使用 Web 服务。

--Link to tutorial--

预编译后我收到以下警告:

Warning 1 There was a mismatch between the processor architecture of the project being built "MSIL" and the processor architecture of the reference "Microsoft.SqlServer.DTSRuntimeWrap, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91", "AMD64". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets

而且我的脚本组件无法运行。

我找到了微软的解决方案here但我不能在 SSIS 中应用它。 感谢任何帮助

-- 编辑 --

我发送了一个new feedback对微软来说,他们正在审查这个问题 - 状态:活跃

最佳答案

这是我的解决方案

我添加了服务引用,而不是 Web 引用

在“解决方案资源管理器”中右键单击“引用”-> 选择“添加服务引用”-> 粘贴地址 (http://www.ibanbic.be/IBANBIC.asmx)-> 单击“开始”按钮 - 然后“确定”

我在代码中添加了以下引用

using MYSCRIPTCOMPONENT.ServiceReference1;
using System.ServiceModel;
using System.Net.Http;

已更新

我的代码是这样的:

    public override void Input0_ProcessInputRow(Input0Buffer Row)
    {
        using (var client = ScriptMain.CreateWebServiceInstance())
        {
            Row.BankIBAN = client.BBANtoIBANandBIC(Row.AccountNum_IsNull ? "" : Row.AccountNum).ToString();
        }
    }

    internal static SC_MYSCRIPTCOMPONENT.ServiceReference1.BANBICSoapClient CreateWebServiceInstance()
    {
        BasicHttpBinding binding = new BasicHttpBinding();
        // I think most (or all) of these are defaults--I just copied them from app.config:
        binding.Security.Mode = BasicHttpSecurityMode.None;
        binding.SendTimeout = TimeSpan.FromMinutes(1);
        binding.OpenTimeout = TimeSpan.FromMinutes(1);
        binding.CloseTimeout = TimeSpan.FromMinutes(1);
        binding.ReceiveTimeout = TimeSpan.FromMinutes(10);
        binding.AllowCookies = false;
        binding.BypassProxyOnLocal = true;
        binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
        binding.MessageEncoding = WSMessageEncoding.Text;
        binding.TextEncoding = System.Text.Encoding.UTF8;
        binding.TransferMode = TransferMode.Buffered;
        System.Net.ServicePointManager.Expect100Continue = false;
        binding.UseDefaultWebProxy = true;
        return new SC_MYSCRIPTCOMPONENT.ServiceReference1.BANBICSoapClient(binding, new EndpointAddress("http://www.ibanbic.be/IBANBIC.asmx"));
    }

编辑

我在运行我的包时遇到错误,它说:

The underlying connection was closed: The connection was closed unexpectedly.

我添加了这行代码(在我的 CreateWebServiceInstance 方法中):

System.Net.ServicePointManager.Expect100Continue = false;

总结

  1. 我添加了服务引用 - 如前所述 here. [STACK OVERFLOW]
  2. 我添加了代码来设置绑定(bind) - 如前所述 here. [STACK OVERFLOW]
  3. 我添加了一行来修复“连接已关闭”-错误 - as provided on MSDN.

关于c# - 在 SSIS 中使用 Web 服务给出 'Mismatch between the processor architecture',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20741590/

相关文章:

sql-server - SSIS存储过程使用临时表2008和2014

sql-server - SSIS自定义数据流组件错误的原因 - 无法升级

c# - WPFToolkit CheckComboBox 宽度问题

c# - SignalR 如何接收自定义数据类型?

c# - Apple Wallet Passs 后端 Web 服务

java - 我如何摆脱 : HTTP Status 405 - HTTP method GET is not supported by this URL?

java - 使用apache cxf动态创建Web服务客户端(修复no operationfound unchecked异常),调用带有身份验证的操作

sql - 将数据从 SQL 导出到 XML - NULL 值

c# - 从表中获取所有结果选项

c# - 使用 C# 和 JS 在 ASP.NET 标签中显示当前日期