tags:

views:

22

answers:

2

Hi ALl,

How can I use IMetadataExchange endpoint to get information about service metadata?

Do I need to implement it in a class like we do for other interfaces ?

Please help me ...

A: 

No, just add the endpoint that exposes IMetadataExchange. You don't have to implement anything.

dmelinosky
A: 

The framework will take care of the implementation for you.

However, you must create a service behavior that enables this.

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>

        <behaviors>
            <serviceBehaviors>
                 <!-- behavior that enables metadata exchanges -->
                <behavior name="mexGet">
                    <serviceMetadata httpGetEnabled="true"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <services>
            <!-- assign the custom behavior here -->
            <service name="MyNamespace.MyImplementation"
                     behaviorConfiguration="mexGet">
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:3849"/&gt;
                    </baseAddresses>
                </host>
                <endpoint
                    address="MyService"
                    binding="wsHttpBinding"
                    contract="MyNamespace.MyServiceInterface"
                    >

                </endpoint>

                <endpoint
                    address="mex"
                    binding="mexHttpBinding"
                    contract="IMetadataExchange">

                </endpoint>
            </service>
        </services>
    </system.serviceModel>
</configuration>
Andrew Shepherd