錯誤概述:我們打開了 Wcf 跟蹤日志記錄,以發現來自第 3 方 Web 服務的隨機斷開連接錯誤。當 Wcf 跟蹤日志記錄打開時,兩個 3rd 方服務中只有一個呼叫錯誤,因為 <ActivityId..../> 添加到 <s:Header>。我們收到的錯誤如下:
顯示將 <ActivityId.....> 添加到未打開 Wcf 跟蹤時不存在的 <s:Header> 的soap 請求。
<ApplicationData>
<TraceData>
<DataItem>
<MessageLogTraceRecord Time="2022-09-02T15:03:48.1440318-05:00" Source="TransportSend" Type="System.ServiceModel.Dispatcher.OperationFormatter OperationFormatterMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Addressing>
<Action>urn:ApiControllerw#BList</Action>
<To>https://www.example.net/api/index.html?ws=1</To>
</Addressing>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Header>
<ActivityId CorrelationId="80f89d90-5b02-47ef-8d43-1cd729d1dd69" xmlns="http://schemas.microsoft.com/2004/09/ServiceModel/Diagnostics">00000000-0000-0000-0000-000000000000</ActivityId>
</s:Header>
<s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<BList xmlns="urn:ApiControllerw"></BList>
</s:Body>
</s:Envelope>
</MessageLogTraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
一旦打開 Wcf 跟蹤,當呼叫其中一個soap 服務時,我們就會開始收到錯誤訊息。該錯誤與不知道如何處理 ActivityID 有關。錯誤如下:
<ApplicationData>
<TraceData>
<DataItem>
<MessageLogTraceRecord Time="2022-09-02T15:03:48.3750527-05:00" Source="TransportSend" Type="System.ServiceModel.Channels.BodyWriterMessage"
xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
<Addressing>
<Action>http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher/fault</Action>
</Addressing>
<s:Envelope
xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
<s:Fault>
<faultcode
xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher"
xmlns="">a:InternalServiceFault
</faultcode>
<faultstring xml:lang="en-US"
xmlns="">Call to company BList operation failed.
</faultstring>
<detail
xmlns="">
<ExceptionDetail
xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HelpLink i:nil="true"></HelpLink>
<InnerException>
<HelpLink i:nil="true"></HelpLink>
<InnerException i:nil="true"></InnerException>
<Message>ApiController and its behaviors do not have a method or closure named "ActivityId".</Message>
<StackTrace>
Server stack trace: at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc&rpc)at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[]ins, Object[]outs, TimeSpan timeout)at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)Exception rethrown at [0]: at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&msgData, Int32 type)at ServiceLibrary.CompanyService.ApiControllerPortType.BList(BListRequest request)at ServiceLibrary.CompanyService.ApiControllerPortTypeClient.ServiceLibrary.CompanyService.ApiControllerPortType.BList(BListRequest request) in C:\TeamCity\buildAgent2\work\TankMonitorServiceLibrary\Service References\CompanyService\Reference.cs:line 3758at ServiceLibrary.CompanyService.ApiControllerPortTypeClient.BList() in C:\TeamCity\buildAgent2\work\ServiceLibrary\Service References\CompanyService\Reference.cs:line 3763at ServiceLibrary.Service.GetBList() in C:\TeamCity\buildAgent2\work\ServiceLibrary\Service.cs:line 311
</StackTrace>
<Type>System.ServiceModel.FaultException</Type>
</InnerException>
<Message>Call to Company BList operation failed.</Message>
<StackTrace>
at ServiceLibrary.Service.GBList() in C:\TeamCity\buildAgent2\work\ServiceLibrary\Service.cs:line 317at SyncInvokeGetBranchList(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.ProcessMessage11(MessageRpc&rpc)at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
</StackTrace>
<Type>System.ServiceModel.CommunicationException</Type>
</ExceptionDetail>
</detail>
</s:Fault>
</s:Body>
</s:Envelope>
</MessageLogTraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
uj5u.com熱心網友回復:
您可以在https://stackoverflow.com/a/28235151找到您的答案
- 從 switchvalue 中洗掉 ActivityTracing
- 將propagateActivity設定為false
有關詳細資訊,請參閱https://learn.microsoft.com/en-us/dotnet/framework/wcf/diagnostics/tracing/activity-id-propagation。
uj5u.com熱心網友回復:
為了創建 ActivityID 欄位,我們應該在服務器端啟用跟蹤和訊息記錄。
<system.diagnostics>
<sources>
<source name="System.ServiceModel" propagateActivity="true" switchValue="Information, ActivityTracing">
<listeners>
<add type="System.Diagnostics.XmlWriterTraceListener" name="xmlLog" initializeData="myLogs.svclog"/>
</listeners>
</source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="false"/>
</diagnostics>
</system.serviceModel>
我們可以看到這個以獲取更多資訊和解決方案的檔案。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/512556.html
標籤:wcf运行时错误痕迹
上一篇:C#/WCF無法使用wsdl發出與SOAPui中相同的請求
下一篇:如何在Python中更改XmlDictionaryReaderQuotas上的MaxBytesPerRead屬性?
