Intimidating at first because of the sheer level of

Info icon This preview shows pages 510–512. Sign up to view the full content.

View Full Document Right Arrow Icon
intimidating at first because of the sheer level of detail they offer, but they’re an indispensable tool for diagnosing communication problems, because they show you exactly what messages were sent and what they contained. The WCF Service Host and Test Client are useful for very simple interactive testing, but a real, useful service needs to be hosted somewhere more permanent. So next, we’ll look at how .NET programs can host WCF services. Hosting a WCF Service WCF services are flexible about their location—any ordinary .NET application can host WCF services, so there’s no such thing as a specialized WCF Service Host project template in Visual Studio. You can host WCF services inside ASP.NET web applica- tions, Windows Services, console applications, or even applications with GUIs built with Windows Forms or WPF. Any process that can accept incoming network con- nections should work, so about the only place you can’t host a WCF service is in a process where security constraints prevent inbound connections, such as a web browser. (For example, Silverlight clients can make outbound WCF connections, but they can’t host a service that accepts incoming connections.) ASP.NET web applications are a particularly popular host environment for WCF serv- ices, because ASP.NET solves a lot of the problems you need to solve for an online service. Web applications automatically become available when a machine starts up— there’s no need for anyone to log in and start a program. ASP.NET provides a robust hosting environment—it’s able to restart after errors, and integrate into diagnostic management systems so that system administrators can discover when problems occur. There are well-understood ways to load-balance web applications across multiple serv- ers. ASP.NET can make use of IIS security features such as integrated authentication. 486 | Chapter 13: Networking
Image of page 510

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
However, ASP.NET is not always the right choice. A WCF service hosted in a web application can’t use the full range of protocols supported by WCF—incoming mes- sages have to arrive by HTTP. Also, web applications usually get to run code only while they are actively handling a request from a client. If you need to perform long-running work that continues even when there are no clients connected right now, a web appli- cation host might be a bad idea, because in some configurations ASP.NET will restart web applications from time to time, or may even shut them down completely when they’ve had no incoming requests lately. So in some situations it might make more sense to write your own host. A Windows Service might be a good bet, as it can start auto- matically when the machine starts. Sometimes it’s useful to host a WCF service inside a normal Windows application.
Image of page 511
Image of page 512
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern