WCF Hosting and service hosting

Source: Internet
Author: User
Tags hosting

To expose a WCF service, you need to provide a hosting environment in which to run the service. Just as the. NET CLR needs to create a hosting environment in managed code, the hosting environment for WCF is also running in the application domain of the process. You can create one or more ServiceHost instances in an application domain, as shown in Figure one:

Figure A managed ServiceHost

WCF does not recommend creating multiple ServiceHost instances in the application domain. If you are hosting multiple services, you can expose multiple WCF services through multiple endpoint in one host. Because application domains are isolated from security, it is necessary to create multiple ServiceHost instances if you need to provide a different security context.

The typical hosting of WCF includes the following four types:

1, "self-hosting" in a Managed application (self hosting)

2. Managed Windows Services (Windows Services Host)

3. Internet Information Services (IIS host)

4. Windows Process activation Service (was host)

The following is a specific example of how these hosts are managed and their related considerations. In such an instance, we define the following service contracts:

namespace BruceZhang.WCF.DocumentsExplorerServiceContract
{
  [ServiceContract]
  public interface IDocumentsExplorerService
  {
    [OperationContract]
    [FaultContract(typeof(DirectoryNotFoundException))]
    DocumentList FetchDocuments(string homeDir);

    [OperationContract]
    Stream TransferDocument(Document document);
  }
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.