【发布时间】:2012-02-02 00:42:48
【问题描述】:
我想了解在发送错误的 WCF 请求时如何在 WCF 返回错误之前捕获异常(日志请求 url)。
例如,我使用 Fiddler 通过以下错误的 Action 元素发布 WCF 请求:
<a:Action s:mustUnderstand="1">http://www.xxx.com/Wrong</a:Action>
WCF 服务向客户端返回以下错误并终止请求。如何捕获请求url,在WCF终止之前捕获异常。
从 WCF 返回的异常:
http://www.w3.org/2005/08/addressing/faulturn:uuid:872ca27f-24c8-4855-8739-e36bd1d921e71e67f1d2-7550-4c41-88cf-acdf8ebd6bd4s:Sendera:ActionNotSupportedThe message with Action 'http://www.xxx.com/Wrong' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
<s:Header>
<a:Action s:mustUnderstand="1">http://www.xxx.com/Wrong</a:Action>
</a:ReplyTo>
<a:To s:mustUnderstand="1">http://www.xxx.com/Service.svc</a:To>
</s:Header>
</s:Envelope>
请注意,当我使用 fiddler 时,实际的请求 url 可能与带有 To 元素的不同。
【问题讨论】:
标签: wcf