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.
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.
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 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.
Edit:
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 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).
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.
来源:https://stackoverflow.com/questions/3548602/wcf-without-http-sys