【发布时间】:2016-09-29 21:26:04
【问题描述】:
我想验证soap 自定义标头中的值以查看它们是否有效。我将根据外部服务对其进行验证。 如果验证失败,我希望能够发回肥皂故障。 有人对如何做到这一点有任何建议吗? 我尝试实现 IOperationInvoker,但是当我在 preinvoke 中抛出异常时,没有响应返回。
【问题讨论】:
标签: wcf wcf-security
我想验证soap 自定义标头中的值以查看它们是否有效。我将根据外部服务对其进行验证。 如果验证失败,我希望能够发回肥皂故障。 有人对如何做到这一点有任何建议吗? 我尝试实现 IOperationInvoker,但是当我在 preinvoke 中抛出异常时,没有响应返回。
【问题讨论】:
标签: wcf wcf-security
您可以使用Message Inspector。
示例 - 关于您使用 AfterReceiveRequest 的服务:
object IDispatchMessageInspector.AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
{
// Retrieve Inbound Object from Request
var header = request.Headers.GetHeader("XXXXX", "X");
// evaluate header and throw FaultException if necessary
return null;
}
【讨论】: