我正在构建的应用程序公开了几个WCF服务(A,B)。在内部,它消耗了我们内部网络(X,Y)上运行的其他几个WCF服务。
使用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和警告级别日志记录。
答案 0 :(得分:2)
试试这个
<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(),"http://opia.api.translink.com.au/ApiLocationService/2012/04/IApiLocationService/ResolveInputServiceFaultFault")]
</add>
</filters>
将动作过滤器中的文本“MyServiceA”替换为MessageLogTraceRecord中的URL&gt;行动