BrainDump
  Home arrow BrainDump arrow Page 2 - Building Blocks for a WCF Service Web Site
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 
Actuate Whitepapers 
Moblin 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
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

Building Blocks for a WCF Service Web Site
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-04-24

    Table of Contents:
  • Building Blocks for a WCF Service Web Site
  • Client behaviors
  • Proxy Initialization
  • Hosting a Service in IIS

  • 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
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Building Blocks for a WCF Service Web Site - Client behaviors


    (Page 2 of 4 )

    Client behaviors implement IEndpointBehavior, also from the System.ServiceModel.Description namespace. There are client behaviors to control debugging, security, serialization, timeouts, and routing. Endpoint behaviors interact with the service model at the client. Endpoint behaviors are configured in the <endpointBehaviors> section. The following example enables exception debugging for callbacks:

      <behaviors>
        <endpointBehaviors>
          <behavior>
            <callbackDebug includeExceptionDetailInFaults="true"/>
          </behavior>
        </endpointBehaviors>
      </behaviors>

    Endpoint behaviors are associated with client endpoints using thebehaviorConfigurationattribute of the<endpoint>section (see Example 1-10).

    Example 1-10. Associating an endpoint behavior to a client endpoint

    <system.serviceModel>
     
    <behaviors>
       
    <serviceBehaviors>
         
    <behavior name="clientBehavior">
            ...
         
    </behavior>
       
    </serviceBehaviors>
     
    </behaviors>
      <client>
       
    <endpoint address="net.tcp://localhost:9000/" binding="netTcpBinding" contract="Client.localhost.IHelloIndigoService" behaviorConfiguration="clientBehavior">
       
    </endpoint>
      </client>
    </system.serviceModel>

    To programmatically configure endpoint behaviors, you can use the object model of the client proxy. TheEndpointproperty of the client proxy has aBehaviorscollection through which you can search for existing behaviors and add behaviors--similar to the way you would for theServiceHost. Example 1-11 shows an example that looks to see if theServiceDebugBehaviorexists, and if not adds it to the collection.

    Example 1-11. Adding the debug service behavior programmatically

    HelloIndigoServiceClient proxy = new HelloIndigoServiceClient();

    ServiceDebugBehavior debugBehavior = proxy.Endpoint.Behaviors.Find<ServiceDebugBehavior>();

    if (debugBehavior == null)
    {
     
    debugBehavior = new ServiceDebugBehavior();

     debugBehavior.IncludeExceptionDetailInFaults = true;
     
    proxy.Endpoint.Behaviors.Add(debugBehavior);
    }

    I will explore other behaviors for the client and service throughout this book as I review features related to each behavior. At this point, I want you to understand how services and client endpoints are related to behaviors.

    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

    - Making Your First Active X Control in Visual...
    - Codes and Packages in Microsoft Project 2007
    - Windows 7: Rumors and Demos
    - XP SP3 Why Me?
    - Breaking Up Your Work in Microsoft Project
    - Breaking Work into Task-Sized Chunks
    - Putting Microsoft`s Worldwide Telescope Unde...
    - 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





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