BrainDump
  Home arrow BrainDump arrow Page 4 - Using Service Templates with Indigo
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  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
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

Using Service Templates with Indigo
By: O'Reilly Media
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-04-17

    Table of Contents:
  • Using Service Templates with Indigo
  • Service Configuration Editor
  • ServiceHost Initialization
  • Enabling Metadata Exchange

  • 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


    Using Service Templates with Indigo - Enabling Metadata Exchange


    (Page 4 of 4 )

    A metadata exchange endpoint is required to support the dynamic generation of proxy and configuration for client applications. You must explicitly enable metadata exchange by adding the endpoint and enabling the metadata exchange behavior.

    A metadata exchange (mex) endpoint is just like any other service endpoint in that it requires an address, contract, and binding. The address for a metadata exchange endpoint requires a base address for the selected binding protocol. The contract must beIMetadataExchange, a predefined service contract belonging to theSystem.ServiceModel.Descriptionnamespace (see Example 1-7).

    Example 1-7. IMetadataExchange contract as defined by the service model

    [ServiceContract(ConfigurationName="IMetadataExchange",Name=
    "IMetadataExchange", Namespace="http://schemas.microsoft.com/ 2006/04/mex")]

    public interface IMetadataExchange
    {
     
    [OperationContract(Action="http://schemas.xmlsoap.org/ws/2004/ 09/transfer/Get", ReplyAction="http://schemas.xmlsoap.org/ws/ 2004/09/transfer/GetResponse", AsyncPattern=true)]
    IAsyncResult BeginGet(Message request,AsyncCallback callback,object state);

      Message EndGet(IAsyncResult result);

      [OperationContract(Action="http://schemas.xmlsoap.org/ws/2004/ 09/transfer/Get", ReplyAction=http://schemas.xmlsoap.org/ws/ 2004/09/transfer/GetResponse)]
      Message Get(Message request);
    }

    As for the binding, there are several predefined mex bindings, includingMexHttpBinding,MexHttpsBinding,MexTcpBinding, andMexNamedPipeBinding. That means you can expose a mex endpoint over HTTP, HTTPS, TCP, or named pipes and have SvcUtil consume those endpoints.

    Like any other endpoint, metadata exchange endpoints can also be consumed at runtime by clients. Applications can call mex endpoints to dynamically generate proxies or just to request information about the associated service.

    The following illustrates a service exposing two TCP endpoints: one for the service, another for metadata exchange:

      <service behaviorConfiguration="serviceBehavior"
      name="HelloIndigo.HelloIndigoService">
        <endpoint address="HelloIndigoService" binding="netTcpBinding" name="netTcp"
     
    contract="HelloIndigo.IHelloIndigoService" />
        <endpoint binding="mexTcpBinding" name="mex" contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp:// localhost:9000/HelloIndigo" />
          </baseAddresses>
        </host>
      </service>

    Supplying the endpoint is not sufficient on its own. The service metadata behavior must also be enabled. Example 1-5 shows you how to enable the behavior by associating a service behavior to the service and including the<serviceMetadata>element. Once the behavior is enabled, you can use SvcUtil for proxy generation against any mex endpoint. For example, to generate a service proxy and configuration using the TCP endpoint with SvcUtil, you can type this instruction at the command line:

      svcutil /d:<YourLearningWCFPath>\Labs\ Chapter1\HelloIndigo\Client  /o:serviceproxy.cs
      /config:app.config
    net.tcp://localhost:9000/HelloIndigo/mex

    It might seem a little annoying at first that you have to enable metadata exchange before you can generate a client proxy. This opt-in behavior is actually a good thing in the long run. You don't want your services exposing endpoints of which you aren't aware or that you dont want to support.

     

    Please check back next week for the continuation of this article.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · 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

    - Introduction to Office Live Workspace
    - Using MS Excel for One-way Analysis of Varia...
    - Comparing Data Sets Using Statistical Analys...
    - Import Blogger Posts into WordPress Using Wi...
    - Download WordPress from an FTP Server and Ru...
    - Install and Run WordPress in XAMPP Local Host
    - What Windows 7 Brings to the Table
    - Virtualization and Sandbox Detection
    - Advanced Firebug Techniques in Windows XP Ho...
    - Editing CSS with Firebug in Windows XP Home
    - Using Firebug in Windows XP Home
    - Migrating to Exchange Server 2007
    - Using System Restore on a Non-Bootable PC
    - Finding Logged on Users and More Scripting S...
    - Developing Macro Commands in MS Excel





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 3 Hosted by Hostway
    Stay green...Green IT