Self-host vs Managed-host rest service and end points
2017-03-26 08:43
387 查看
ServiceHosts
Servicehost namespace and class is the program model provided by WCF to hsot the web service in executable process that load with CLR.
WebServiceHost is derive from servicehost which is more web service friendly, it saves you the effort to create endpoints as long as your service provide just one type of contract. and its default binding is webhttpbinding.
The code below is fully functional given the endpoints creation is totally wiped out
Self host vs managed host
Self host web service means the life time, security and configuration is managed by executable process it self. the ServiceHost provide a method Open() and Close(), which allows you to on/off the webservice container or host
View Code
in the contrast, Managed host ones are managed by IIS.
Servicehost namespace and class is the program model provided by WCF to hsot the web service in executable process that load with CLR.
WebServiceHost is derive from servicehost which is more web service friendly, it saves you the effort to create endpoints as long as your service provide just one type of contract. and its default binding is webhttpbinding.
The code below is fully functional given the endpoints creation is totally wiped out
WebServiceHost host; var binding = new WebHttpBinding(WebHttpSecurityMode.None); binding.CrossDomainScriptAccessEnabled = true; Uri uri = new Uri(_address); Uri[] baseAddresses = new Uri[] { uri }; host = new WebServiceHost(_servicetype, uri); //host.AddServiceEndpoint(_contractype, binding, "/workorders").EndpointBehaviors.Add(new WebHttpBehavior()); //host.AddServiceEndpoint(_contractype, binding, "").EndpointBehaviors.Add(new WebHttpBehavior()); return host;
Self host vs managed host
Self host web service means the life time, security and configuration is managed by executable process it self. the ServiceHost provide a method Open() and Close(), which allows you to on/off the webservice container or host
public void StartupStub() { host = base.CreateEndPoint(); host.Open(); } public void StopStub() { if (host != null) { host.Close(); } }
View Code
in the contrast, Managed host ones are managed by IIS.
相关文章推荐
- Web.Config - create WCF REST Service and host in Windows Azure
- 使用VS自动化模型代码片段 Get DTE and UIService
- Exchange Web Services and VS 2008 (Missing ExchangeServiceBinding)
- Managed Service Accounts: Understanding, Implementing, Best Practices, and Troubleshooting
- Difference between WCF and Web API and WCF REST and Web Service
- 使用ASP.Net WebAPI构建REST服务(六)——Self-Host
- 15.1 End points and reachability
- Managed Metadata Service Application(四)Enterprise metadata and keywords
- Host a WCF Service in a Managed Application
- How to create, host, test and consume a WCF Web Service
- stopSelf() vs stopSelf(int) vs stopService(Intent)
- How to: Host and Run a Basic Windows Communication Foundation Service
- Using ServiceHost and ChannelFactory
- Style of WebService: REST vs. SOAP
- end()与andSelf()
- How to: Host a WCF Service in a Managed Windows Service
- Exchange Web Services and VS 2008 (Missing ExchangeServiceBinding)
- Host多个WCF服务(Self-host)Start ServiceHosts for all configured Services
- Self-learning: Hosted Service Name and Storage Name
- How to Find the Self Service Related File Location and Versions