gpt4 book ai didi

c# - WSDL 导出扩展中的周期性异常

转载 作者:可可西里 更新时间:2023-11-01 09:07:43 25 4
gpt4 key购买 nike

我有一个 SOAP 服务,现在已经运行了一个多月了。在过去的两周里,我们遇到过服务会随机开始生成异常的情况。每次,它们似乎都与导出扩展有关,并且错误总是沿着以下几行:

An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior

“System.ArgumentException:指定节点来自不同的文档上下文。”似乎每次都是根本原因。

让我烦恼的是这项服务在一个半月内没有改变,所以我很困惑我们会突然收到参数错误。这是否更能说明潜在问题(内存泄漏或类似问题)?

我对运行它的机器的访问权限非常有限,但可以根据需要尝试获取任何支持信息。这是 wsdl 返回的完整异常:

    An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is:
System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
Endpoint: [endpoint name here... hidden for security] ----> System.ArgumentException: The named node is from a different document context.
at System.Xml.XmlAttributeCollection.Append(XmlAttribute node)
at System.ServiceModel.Description.SoapHelper.CreateSoapFaultBinding(String name, WsdlEndpointConversionContext endpointContext, FaultBinding wsdlFaultBinding, Boolean isEncoded)
at System.ServiceModel.Description.MessageContractExporter.MessageBindingExporter.ExportMessageBinding(OperationDescription operation, Type messageContractExporterType)
at System.ServiceModel.Description.WsdlExporter.CallExtension(WsdlEndpointConversionContext endpointContext, IWsdlExportExtension extension)
--- End of inner ExceptionDetail stack trace ---
at System.ServiceModel.Description.ServiceMetadataBehavior.MetadataExtensionInitializer.GenerateMetadata()
at System.ServiceModel.Description.ServiceMetadataExtension.EnsureInitialized()
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.InitializationData.InitializeFrom(ServiceMetadataExtension extension)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.GetInitData()
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.TryHandleMetadataRequest(Message httpGetRequest, String[] queries, Message& replyMessage)
at System.ServiceModel.Description.ServiceMetadataExtension.HttpGetImpl.ProcessHttpRequest(Message httpGetRequest)
at SyncInvokeGet(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)

编辑:我想澄清一下服务并不总是会遇到此异常。有时 wsdl 返回正常,其他时候它抛出此异常(我会说目前它是获得成功返回的 50/50 镜头)。我不知道为什么。我最初的想法是环境问题,但如果真是这样,我不知道该向托管团队指出何处。

编辑 2:自从询问初始查询后,我发现客户已将服务放在多台服务器上并正在使用负载平衡器,我相信这解释了我们得到的随机响应。我已经建议他们如何至少隔离问题并从那里着手。

最佳答案

我有一个类似的错误。在我的例子中,事实证明对 WsdlExporter.GetGeneratedMetaData() 的实例调用不是线程安全的,并且是在 Parallel.Foreach 中调用的。所以添加简单的锁定解决了这个问题。

关于c# - WSDL 导出扩展中的周期性异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5939856/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com