Next is a systemservicemodel elementin fact all the

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

View Full Document Right Arrow Icon
Next is a <system.serviceModel> element—in fact, all the remaining contents of the App.config file are inside this element. This is where all WCF configuration lives, re- gardless of the type of host application. The first element inside the WCF configuration is <services> . This contains a <service> element for each service the program will host. Visual Studio has added two: one for the Service1 service that we’re not using, and one for the ChatService we wrote. Since we don’t need the Service1 service, we can delete that first <service> element and everything it contains. This leaves the <service> element for our ChatService . It begins: <service name="ChatServerLibrary.ChatService"> The name attribute is the name of the class that implements the service, including the namespace. Inside the <service> element we find some <endpoint> elements. Remem- ber that earlier we said WCF can make a single service implementation accessible through multiple communication mechanisms. You do that by adding one endpoint for each mechanism you wish to support. Here’s the first endpoint Visual Studio added for us: <endpoint address="" binding="wsHttpBinding" contract="ChatServerLibrary.IChatService"> <identity> <dns value="localhost" /> </identity> </endpoint> 488 | Chapter 13: Networking
Image of page 512

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

View Full Document Right Arrow Icon
An endpoint is defined by three things: an address , a binding , and a contract sometimes referred to collectively as the ABC of WCF. The address is typically a URL —it’s the address a client would use to connect to the service. In this case the address is blank, which means WCF will deduce the address for us—we’ll see how in a moment. The binding determines the communication technology that WCF will use on this endpoint. Here we’ve used one of the built-in bindings called wsHttpBinding . The “ws” denotes that this uses the various web service standards that begin with WS-. So this binding supports standards such as WS-ADDRESSING and WS-SECURITY. This is a feature-rich binding, and it may use features that some clients don’t understand—it’s not supported by Silverlight, for example. If you wanted to use the basic profile that Silverlight clients support, you’d specify basicHttpBinding here instead. But for this application, you can leave the binding as it is. Finally, the contract attribute here contains the name of the interface type that defines the operation contract for our service. We already looked at contracts—this refers to the interface we saw in Example 13-1 and modified in Example 13-2 . Inside the <endpoint> element you’ll see an <identity> element. This is intended for scenarios where the service needs to be able to identify itself securely to a client—for example, in a banking application you’d want to be confident that you’re really talking to your bank. But we’re not going to get into security in this example, so we can delete the <identity> element and its contents.
Image of page 513
Image of page 514
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