BrainDump
  Home arrow BrainDump arrow Page 3 - Services and the WCF
Iron Speed
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Dedicated Servers 
Download TestComplete 
Windows Web Hosting
 
IBM® developerWorks 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
BRAINDUMP

Services and the WCF
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-04-03

    Table of Contents:
  • Services and the WCF
  • Defining a Service
  • Exposing Service Endpoints
  • Creating a Client Proxy

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Services and the WCF - Exposing Service Endpoints
    (Page 3 of 4 )

    Endpoints expose service functionality at a particular address. Each endpoint is associated with a particular contract and a set of protocols as defined by the binding configuration. For each service, one or more endpoints may be exposed if multiple contracts are present or if multiple protocols are desired to access service functionality. Figure 1-20 illustrates how the ServiceHost instance exposes endpoints to clients and how the proxy invokes service operations at a particular endpoint.


    Figure 1-20.  ServiceHost exposes endpoints, and client proxies target a specific endpoint

    As the lab illustrates, to create a service endpoint you provide an address, a binding, and a contract.

    Addresses

    The address can be a complete URI or a relative address like that used in the lab. The following shows you how to initialize an endpoint with a complete URI without supplying a base address to the ServiceHost:

      using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService)))
      {
        host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService),
      new BasicHttpBinding(), http://localhost:8000/HelloIndigo/ HelloIndigoService);
        // other code
      }

    If you supply a relative address it is concatenated with theServiceHost base address for the matching protocol. The following illustrates providing an HTTP base address to theServiceHostconstructor and providing a relative address toAddServiceEndpoint():

      using (ServiceHost host = new ServiceHost(typeof(HelloIndigo.HelloIndigoService),
      new Uri(http://localhost:8000/HelloIndigo)))
      {
       
    host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService),
      new BasicHttpBinding(), "HelloIndigoService");
        // other code
      }

      // Resulting endpoint address 
      http://localhost:8000/HelloIndigo/ HelloIndigoService

    In practice, a base address should be supplied for each transport protocol over which the service can be accessed--for example, HTTP, TCP, named pipes, or MSMQ. In the event an endpoint address includes a complete URI, the base address will be ignored.

    Using relative endpoint addressing makes is possible to modify the base URI to move all associated relative endpoints to a new domain or port. This can simplify the deployment process.

    Bindings

    The binding provided to an endpoint can be any of the standard bindings supplied by the service model. In this example, a new instance of the standard BasicHttpBinding is used to initialize the endpoint:

      host.AddServiceEndpoint(typeof(HelloIndigo.IHelloIndigoService),
        new BasicHttpBinding(), "HelloIndigoService");

    The choice of binding defines the communication channel. For an endpoint,BasicHttpBinding, for example, supports requests over HTTP protocol sent in text format without any additional protocols for addressing, reliable messaging, security, or transactions.

    In this chapter, you will employ other standard bindings, but you should look to Chapter 3 for an in-depth discussion of bindings, channels, and overall service model architecture.

    Contracts

    Each endpoint is associated with a particular service contract that determines the operations available at the endpoint. Only one service contract exists in this lab, but a service with multiple contracts could expose a different endpoint for each contract it wants to make accessible to clients.

    More BrainDump Articles
    More By O'Reilly Media


       · This article is an excerpt from the book "Learning WCF A Hands-on Guide," published...
     

    Buy this book now. This article is excerpted from chapter 1 of the book Learning WCF A Hands-on Guide, written by Michele Leroux Bustamante (O'Reilly, 2007; ISBN: 0596101627). Check it out today at your favorite bookstore. Buy this book now.

    BRAINDUMP ARTICLES

    - Handling Multiple Contracts with Indigo
    - Cleaning Out Your Data in XP
    - Multiple Service Contracts and Indigo
    - Cleaning Out Your Programs in XP
    - Handling Metadata with Indigo
    - Building Blocks for a WCF Service Web Site
    - Help! I Need Some Remote Assistance
    - Using Service Templates with Indigo
    - Windows XP Tips for Task Manager
    - Generating Clients and Services with Indigo
    - Vista SP1, A Review
    - Services and the WCF
    - VBScript: Final Date Functions
    - Creating Services with the WCF
    - The Resource View of the MFC

     
    Accelerating Trading Partner Performance
     
    Competing on Analytics
     
    Cost Effective Scaling with Virtualization and Coyote Point Systems
     
    Five Checkpoints to Implementing IP Telephony
     
    Hosted Email Security: Staying Ahead of New Threats
     




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway