从Azure Functions连接到WCF服务并对程序集绑定进行故障排除 [英] Connecting to WCF service from Azure Functions and trouble-shooting assembly bindings

查看:65
本文介绍了从Azure Functions连接到WCF服务并对程序集绑定进行故障排除的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在哪里可以看到Azure函数试图加载的程序集?(就像Windows上的fuslogvw)

Where can I see the Assembly that Azure functions is trying to load ? (Like fuslogvw on windows)

更新根据要求更新标题,以更好地反映接受的答案

Update Update the title as requested to better reflect the accepted answer

更新

将我的代码更改为使用WebClient'手动'构造SOAP请求,并且它可以正常工作...因此,我认为WCF服务代理在Azure功能的沙箱中无法正常运行...不过,我仍然希望关于如何查看程序集绑定日志视图的答案.

Changed my code to 'manually' construct the SOAP request using WebClient and it works ... so me thinks somewhere the WCF service proxy is not playing well within the sandbox that is Azure Functions ... Nevertheless I would still like an answer as to how we can see the Assembly binding log views.

原始帖子

我一直遇到相同的错误:

I keep getting the same error :

2016-11-17T10:32:44.392 System.IO.FileNotFoundException:文件名,目录名称或卷标签语法不正确.(来自的例外HRESULT:0x8007007B)

2016-11-17T10:32:44.392 System.IO.FileNotFoundException: The filename, directory name, or volume label syntax is incorrect. (Exception from HRESULT: 0x8007007B)

服务器堆栈跟踪:

在System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32errorCode,IntPtr errorInfo)

at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)

在Microsoft.Win32.Fusion.ReadCache(ArrayList alAssems,String名称,UInt32 nFlag)

at Microsoft.Win32.Fusion.ReadCache(ArrayList alAssems, String name, UInt32 nFlag)

在System.Reflection.RuntimeAssembly.EnumerateCache(AssemblyNamepartialName)

at System.Reflection.RuntimeAssembly.EnumerateCache(AssemblyName partialName)

在System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(AssemblyNamean,证据安全证据,StackCrawlMark&stackMark)

at System.Reflection.RuntimeAssembly.LoadWithPartialNameInternal(AssemblyName an, Evidence securityEvidence, StackCrawlMark& stackMark)

在System.Reflection.Assembly.LoadWithPartialName(StringpartialName,证据安全性证据)

at System.Reflection.Assembly.LoadWithPartialName(String partialName, Evidence securityEvidence)

在System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type类型,字符串defaultNamespace,XmlSerializerImplementation&合同)

at System.Xml.Serialization.TempAssembly.LoadGeneratedAssembly(Type type, String defaultNamespace, XmlSerializerImplementation& contract)

,位于System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping []映射,类型类型)

at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)

在System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GenerateSerializers()

at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GenerateSerializers()

在System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GetSerializer(Int32处理)

at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GetSerializer(Int32 handle)

在System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.MessageInfo.get_BodySerializer()

at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.MessageInfo.get_BodySerializer()

在System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter编写器,MessageVersion版本,字符串操作,MessageDescriptionmessageDescription,对象returnValue,Object []参数,布尔值isRequest)

at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.SerializeBody(XmlDictionaryWriter writer, MessageVersion version, String action, MessageDescription messageDescription, Object returnValue, Object[] parameters, Boolean isRequest)

在System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter编写器,MessageVersion版本,Object []参数,ObjectreturnValue,布尔值isRequest)

at System.ServiceModel.Dispatcher.OperationFormatter.SerializeBodyContents(XmlDictionaryWriter writer, MessageVersion version, Object[] parameters, Object returnValue, Boolean isRequest)

在System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter作家)

at System.ServiceModel.Dispatcher.OperationFormatter.OperationFormatterMessage.OperationFormatterBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer)

在System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter作家)

at System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer)

在System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter作家)

at System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer)

在System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(消息消息,信息流)

at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.WriteMessage(Message message, Stream stream)

在System.ServiceModel.Channels.HttpOutput.WriteStreamedMessage(TimeSpan超时)

at System.ServiceModel.Channels.HttpOutput.WriteStreamedMessage(TimeSpan timeout)

在System.ServiceModel.Channels.HttpOutput.Send(TimeSpan超时)

at System.ServiceModel.Channels.HttpOutput.Send(TimeSpan timeout)

在System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(消息消息,TimeSpan超时)

at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.SendRequest(Message message, TimeSpan timeout)

在System.ServiceModel.Channels.RequestChannel.Request(消息消息,TimeSpan超时)

at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout)

在System.ServiceModel.Dispatcher.RequestChannelBinder.Request(消息消息,TimeSpan超时)

at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)

在System.ServiceModel.Channels.ServiceChannel.Call(字符串操作,Boolean oneway,ProxyOperationRuntime操作,Object [] ins,Object []超时,TimeSpan超时)

at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)

在System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessagemethodCall,ProxyOperationRuntime操作)

at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)

在System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage消息)

at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

异常重新抛出为[0]:

Exception rethrown at [0]:

在System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessagereqMsg,IMessage retMsg)

at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)

在System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData,Int32类型)

at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)

推荐答案

当前,不支持查看程序集绑定日志.启用诊断日志将有助于调试大多数错误.还可以查看记录提示和技巧.

Currently, there is no support to view assembly binding logs. Enabling diagnostic logs will help debug most of the errors. Also take a look at logging tips and tricks.

以下是从您的函数连接到Azure托管的WCF服务的示例:

Here is a sample for connecting to a WCF service hosted in Azure from your function:

  1. 转到功能应用程序设置->转到Kudu->转到D:\ home \ site \ wwwroot \ YourFunction
  2. 创建文件夹 bin
  3. 上传System.ServiceModel.dll
  4. 上载WCF服务合同IService1.csx.您可以从Kudu或在门户网站上查看文件来完成此操作

  1. Got to Function App Settings --> Go to Kudu --> Go to D:\home\site\wwwroot\YourFunction
  2. Create folder bin
  3. Upload System.ServiceModel.dll
  4. Upload WCF service contract IService1.csx. You can do this from either Kudu or View Files on the portal

 #r "System.ServiceModel.dll"

 using System.ServiceModel;

 [ServiceContract]
 public interface IService1
 {
     [OperationContract]
     string GetData(int value);

     [OperationContract]
     string WelComeMessage(String name);
 }

  • 调用WCF端点的示例队列触发器:

  • Sample queue trigger that invokes WCF endpoint:

    #r "System.ServiceModel.dll"
    #load "IService1.csx"
    
    using System;
    using System.ServiceModel;
    
    public static void Run(string myQueueItem, TraceWriter log)
    {
        log.Info($"C# Queue trigger function processed: {myQueueItem}");
    
        BasicHttpBinding b = new BasicHttpBinding();
        EndpointAddress ea = new  EndpointAddress("http://YourServiceAddress/service1.svc?wsdl");
        var myChannelFactory = new ChannelFactory<IService1>(b, ea);
        IService1 client = myChannelFactory.CreateChannel();
        var msg= client.WelComeMessage("HelloWorld");
        ((ICommunicationObject)client).Close();
        log.Info($"Hello from WCF: {msg}");
     }
    

  • 希望这会有所帮助!

    这篇关于从Azure Functions连接到WCF服务并对程序集绑定进行故障排除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆