BrainDump
  Home arrow BrainDump arrow Page 2 - Generating Clients and Services with Indig...
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 
IBM Developerworks
 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

Generating Clients and Services with Indigo
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 1
    2008-04-10

    Table of Contents:
  • Generating Clients and Services with Indigo
  • Configuring service endpoints using the Service Configuration Editor
  • Generating a proxy with Add Service Reference
  • Generating a proxy using the Service Model Metadata Utility

  • 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

    Free Web 2.0 Code Generator! Generate data entry 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!

    Generating Clients and Services with Indigo - Configuring service endpoints using the Service Configuration Editor
    (Page 2 of 4 )

    In this section, you will provide an endpoint for the ServiceHost--this time using the Service Configuration Editor. Unlike in the previous lab, endpoints will be configured using an external application configuration file. As such, you'll open the application configuration file for the Host application using the tool to configure ServiceHost endpoints in that file.

    1. Go to theHostproject and right-click on the app.config file. Select Edit WCF Configuration. You'll see the Service Configuration Editor interface shown in Figure 1-21. Go to the Tasks pane and click "Create a New Service"; the New Service Element Wizard will be displayed.

      Follow these instructions as you go through each page in the wizard:

      a. On the first page, you are asked to provide the service type. Browse to<YourLearningWCFPath>\Labs\Chapter1\HelloIndigo\Host\Bin\Debug and select Host.exe. The Type Browser dialog (shown in Figure 1-22) will listHost.HelloIndigoServiceas the only service available in the assembly. Select it from the list and click Open. Click Next to continue.

      b. Now you will be asked to specify a service contract. There is only one service contract implemented byHelloIndigoService, so the selected service contract should beHost.IHelloIndigoService. Click Next to continue.

      c. Select HTTP as your service communication mode and click Next.

      d. Select Basic Web Services interoperability as your interoperability method and click Next.

      e. Now you'll be asked to provide an endpoint address. Here you can provide a relative address by clearing the current text and typing "HelloIndigoService." Click Next.

      f. Review the configuration you have chosen for the service, then click Finish. 


      Figure 1-21.  Service Configuration Editor for WCF
    2. Go to the Configuration pane in the Service Configuration Editor interface and expand the Endpoints folder beneathHost.HelloIndigoService. Select the only endpoint labeled (Empty Name).

      Go to the Service Endpoint pane, and in the General tab, provide the namebasicHttpas shown in Figure 1-23. At this point, you have created a single, relative service endpoint.


      Figure 1-22.  The service type browser lists all service types in a particular assembly


      Figure 1-23.  Configuring a service endpoint using the Service Configuration Editor
    3. In this lab, the client will generate a proxy using SvcUtil. To support this, you'll enable the metadata exchange behavior by adding a behavior to the service configuration.

      Go to the Configuration section and expand the Advanced folder. Select Service Behaviors and go to the Tasks pane to select New Service Behavior Configuration.

      Go to the Behavior pane and set the configuration name toserviceBehavior. Click the Add button to add a behavior element and selectserviceMetadata from the list provided.

      Go to the Configuration pane and you'll now see a newserviceMetadatanode beneathserviceBehavior. Select the node and review the default settings in the General tab.
    4. The behavior must be explicitly associated to the service. Go to the Configuration pane and select the service node,Host.HelloIndigoService. Go to the Service pane and set theBehaviorConfigurationproperty toserviceBehavior(you can select it from the dropdown list).
    5. Enabling the metadata behavior is a good start, but a new endpoint is also required to support metadata exchange. Go to the Configuration pane, right-click on the Endpoints folder, and select New Service Endpoint.

      Go to the Service Endpoint pane and set the name tomex. In the Endpoint Properties section, set the Binding tomexHttpBinding. For the Contract property type, selectIMetadataExchange.
    6. In order to support metadata exchange, the host must have a base address for the metadata exchange protocol being used. In addition, since you supplied a relative address for the service endpoint, it also requires a base address matching the binding protocol. In this case, an HTTP base address will be used.

      Go to the Configuration pane and select theHost node beneathHost. HelloIndigoService. Go to the Host pane and select New to create a new base address. From the Base Address Editor, supply the following base address: http://localhost:8000/HelloIndigo.
    7. Save the configuration settings you just generated. Select File -> Save followed by File -> Exit. Return to Visual Studio and open the app.config for theHostproject. You will see a<system.serviceModel>section like the one shown in Example 1-5.
    8. Compile theHostproject and then run it. Leave the host running for the next step.

    Example 1-5. Service model configuration generated by Service Configuration Editor

    <system.serviceModel>
      <behaviors>
        <serviceBehaviors>
          <behavior name="serviceBehavior">
            <serviceMetadata />
          </behavior>
        </serviceBehaviors>
      </behaviors>
     
    <services>
        <service behaviorConfiguration="serviceBehavior" name="Host.HelloIndigoService" >
          <endpoint address="HelloIndigoService" binding="basicHttpBinding"
    name="basicHttp" contract="Host.IHelloIndigoService" />
         
    <endpoint binding="mexHttpBinding" name="mex" contract="IMetadataExchange" />
         
    <host>
           
    <baseAddresses>
              <add baseAddress="http://localhost:8000/HelloIndigo" />
            </baseAddresses>
          </host>
        </service>
      </services>   
    </system.serviceModel>

    You just created a declarative configuration for theServiceHost, instead of programmatically initializing its base addresses and service endpoints. In addition, you enabled the service metadata behavior and created a metadata exchange endpoint so that clients can generate a proxy using SvcUtil. That's the next step.

    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 3 hosted by Hostway