WCF:使用 OperationContext 区分 REST 和 SOAP 请求 [英] WCF: Distinguish between REST and SOAP requests using the OperationContext

查看:35
本文介绍了WCF:使用 OperationContext 区分 REST 和 SOAP 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 WCF 安全中,给定当前的 OperationContext,确定请求是 SOAP 请求还是 REST 请求的最佳方法是什么?

In WCF security, given the current OperationContext, what is the best way to determine whether the request is a SOAP request or a REST request?

推荐答案

您可以在 ChannelDispatcher 上查看绑定名称:

You could look at the binding name on the ChannelDispatcher:

string bindingName = OperationContext.Current
                        .EndpointDispatcher.ChannelDispatcher.BindingName;

对于 REST,它将是 webHttpBinding - 其他任何东西都是 SOAP.

For REST, it would be webHttpBinding - anything else would be SOAP.

这篇关于WCF:使用 OperationContext 区分 REST 和 SOAP 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆