从Azure函数调用WCF终结点

时间:2019-01-31 10:42:05

标签: azure wcf .net-core azure-functions azure-functions-runtime

我有一个用dotnet核心编写的v2 Azure函数。我想像这样调用旧式WCF端点:

        basicHttpBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;

        var factory = new ChannelFactory<IMyWcfService>(basicHttpBinding, null);
        factory.Credentials.UserName.UserName = "foo";
        factory.Credentials.UserName.Password = "bar";

        IMyWcfService myWcfService = factory.CreateChannel(new EndpointAddress(new Uri(endpointUri)));

        ICommunicationObject communicationObject = myWcfService as ICommunicationObject;

        if ( communicationObject != null)
            communicationObject.Open();

        try
        {
            return await myWcfService.GetValueAsync());
        }            
        finally
        {

            if (communicationObject != null)
                communicationObject.Close();

            factory.Close();
        }

当我从单元测试中调用它时,此方法有效,因此我知道代码可以在Windows 10上正常运行。但是,当我在func主机中调试时,会丢失依赖项异常。我复制了两个dll文件:System.Private.RuntimeSystem.Runtime.WindowsRuntime到in目录中,但是已经到达了行末,只有一个例外

  

无法从程序集“ mscorlib”中加载类型“ System.Threading.Tasks.AsyncCausalityTracer”

这似乎是一个运行时的兔子洞,我不想停下来。有没有人从Azure函数成功调用Wcf服务?我应该添加哪些依赖项才能开始工作?

0 个答案:

没有答案