You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

开启WCF跟踪日志后,ActivityId加入SOAP报头引发调用错误

WCF跟踪日志引发第三方SOAP服务调用失败

为排查第三方Web服务的随机断开问题,开启WCF跟踪日志后,其中一个第三方服务调用出现错误。原因是开启跟踪时,WCF会自动在SOAP请求的<s:Header>中添加<ActivityId/>节点,而关闭跟踪日志时该节点不存在,第三方服务无法识别并处理这个节点。

报错的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>

服务返回的错误响应

<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>

核心错误提示

ApiController及其行为中没有名为“ActivityId”的方法或闭包,最终导致BList操作调用失败。


内容的提问来源于stack exchange,提问作者CodingUp

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 18:25:34