我正在构建的应用程序公开了几个WCF服务(A,B)。内部使用了运行在我们内部网络上的多个其他WCF服务(X,Y)。
通过使用WCF消息记录,我希望仅记录服务A、B与调用它们的外部客户端之间的流量。
不应通过WCF记录服务A、B和后端服务X、Y之间的任何数据。
通过system.serviceModel/diagnostics/messageLogging/filters进行过滤部分成功:
<filters>
<add nodeQuota="10" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
/s:Envelope/s:Header/*[contains(text(),"MyServiceA")]
</add>
<add nodeQuota="10" xmlns:s="http://schemas.xmlsoap.org/soap/envelope/" xmlns:a="http://schemas.microsoft.com/ws/2005/05/addressing/none">
/s:Envelope/s:Header/a:Action[contains(text(),"MyServiceA")]
</add>
</filters>
但是这无法捕获我们服务的响应,因为SOAP 响应 不包含可过滤的文本。
WCF MessageLogTraceRecord 包含 SOAP Action,但我似乎无法构造筛选器来访问它:
<MessageLogTraceRecord>
<Addressing xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace>
<Action>http://opia.api.translink.com.au/ApiLocationService/2012/04/IApiLocationService/ResolveInputServiceFaultFault</Action>
</Addressing>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
<s:Body>
...
启用了WCF消息记录和端到端跟踪,所有选项均设置为true。启用了ActivityTracing和Warning级别日志记录。