没有HTTP.SYS的WCF [英] WCF without HTTP.SYS

查看:261
本文介绍了没有HTTP.SYS的WCF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在WCF中使用HTTP绑定时,我需要授予自己特殊权限才能绑定到该端口/路径。我理解这是因为WCF通过 http.sys 驱动程序接受HTTP流量。

When using a HTTP binding in WCF, I need to grant myself special permissions to be able to bind to that port/path. I understand this is because WCF accepts HTTP traffic through the http.sys driver.

在过去的日子里,我们可以新建一个套接字并绑定到任何未使用的旧端口,而不是管理员。 NetTcpBinding仍然能够做到这一点。

In the olden days, we could new up a socket and bind to any old port that wasn't in use, without being an admin. NetTcpBinding is still able to do this.

如果我不关心http.sys,有没有办法告诉WCF不要使用它,而只是打开一个普通的旧套接字,而使用HTTP绑定?

If I don't care for http.sys, is there a way to tell WCF not to use it, and instead to just open up a regular old socket while still using HTTP bindings?

推荐答案

WCF基于HTTP的绑定依赖于 HttpListener 这是围绕HTTP API的托管包装的类。 HTTP API取决于操作系统处理http请求的方式。因此,如果您使用使用http.sys驱动程序(Windows 2003和更高版本)的操作系统,则您依赖它。

WCF HTTP based bindings are dependent on HttpListener class which is managed wrapper around HTTP API. HTTP API is dependent on the way how operation system process http requests. So if you use operation system which uses http.sys driver (Windows 2003 and newer) you are dependent on it.

编辑:

基于对卡西尼的非常好的争论,我花了两个小时在Reflector中。以下描述仅是我的假设。我没有找到任何关于它的信息,所以也许我完全错了。

Based on very good argument about Cassini I spent two hours in Reflector. Following description is only my assumption. I haven't found any information about it so maybe I'm completely wrong.

WCF内部包含一些名为 HttpTransportManager的抽象类此类由内部类派生 HostedHttpTransportManager SharedHttpTransportManager (此版本也存在于HTTPS版本中)。前一个不依赖于 HttpListener ,但后者是。当WCF托管在ASP.NET管道中时使用前者 - 来自System.ServiceModel的内部类 HttpModule HttpHandler .Activation程序集使用 HostedHttpRequestAsyncResult 依赖于 HostedHttpTransportManager 。在创建 HttpChannelListener 时使用后者(自托管)。

WCF internally contains some abstract class called HttpTransportManager this class is derived by internal classes HostedHttpTransportManager and SharedHttpTransportManager (this one also exists in version for HTTPS). The former one is not dependent on HttpListener but the latter one is. The former one is used when WCF is hosted in ASP.NET pipeline - internal classes HttpModule and HttpHandler from System.ServiceModel.Activation assembly use HostedHttpRequestAsyncResult dependent on HostedHttpTransportManager. The later one is used when HttpChannelListener is created (self-hosting).

我的结论是,在ASP.NET管道中托管的WCF服务并不直接依赖于http.sys,而是托管管道的IIS。这允许创建自定义Web服务器,该服务器不依赖于http.sys,但能够托管ASP.NET等WCF。我认为这就是卡西尼所做的。自托管WCF服务始终依赖于http.sys。

My conclusion is that WCF service hosted in ASP.NET pipeline is not directly dependent on http.sys but the IIS hosting the pipeline is. This allows creating custom web server which will not be dependent on http.sys but will be able to host ASP.NET and so WCF. I think this is what Cassini does. Self hosted WCF service is always dependent on http.sys.

如上所述,这只是基于一些快速逆向工程的猜测。

As I written above this is only my guessing based on some quick reverse engineering.

这篇关于没有HTTP.SYS的WCF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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