在WCF终止客户端请求之前钩住WCF

在WCF终止客户端请求之前钩住WCF,wcf,Wcf,我想了解当发送错误的WCF请求时,如何在WCF返回错误之前捕获异常(日志请求url) 例如,我使用Fiddler发布WCF请求时使用了下面的错误操作元素: <a:Action s:mustUnderstand="1">http://www.xxx.com/Wrong</a:Action> http://www.xxx.com/Wrong WCF服务将以下错误返回给客户端并终止请求。如何捕获请求url,在WCF终止异常之前捕获异常 从WCF返回的异常: http://w

我想了解当发送错误的WCF请求时,如何在WCF返回错误之前捕获异常(日志请求url)

例如,我使用Fiddler发布WCF请求时使用了下面的错误操作元素:

<a:Action s:mustUnderstand="1">http://www.xxx.com/Wrong</a:Action>
http://www.xxx.com/Wrong
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>
http://www.w3.org/2005/08/addressing/faulturn:uuid:872ca27f-24c8-4855-8739-e36bd1d921e71e67f1d2-7550-4c41-88cf-acdf8ebd6bd4s:Sendera:ActionNotSupported带有操作的消息'http://www.xxx.com/Wrong由于EndpointDispatcher上的ContractFilter不匹配,无法在接收器上处理。这可能是因为合同不匹配(发送方和接收方之间的操作不匹配)或发送方和接收方之间的绑定/安全不匹配。检查发送方和接收方是否具有相同的合同和相同的绑定(包括安全要求,例如消息、传输、无)。
http://www.xxx.com/Wrong
http://www.xxx.com/Service.svc
请注意,当我使用fiddler时,实际的请求url可能与带有To元素的请求url不同。

请查看接口。如果配置正确,所有异常都会通过它。我没有试过,但在HandleError中,您可以记录任何您想要的内容。OperationContext可以提供您正在查找的数据。看看这个界面。如果配置正确,所有异常都会通过它。我没有试过,但在HandleError中,您可以记录任何您想要的内容。OperationContext可以提供您正在查找的数据。看看这个