Click here to Skip to main content
15,891,849 members
Articles / Programming Languages / C#

WS-Discovery for WCF

Rate me:
Please Sign up or sign in to vote.
4.95/5 (31 votes)
27 Nov 2008CPOL12 min read 139.7K   3.3K   86  
This article describes the design, implementation, and usage of WS-Discovery for Windows Communication Foundation (WCF).
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging"  switchValue="Verbose">
        <listeners>
          <add name="messages"
          type="System.Diagnostics.XmlWriterTraceListener"
          initializeData="c:\messages.svclog" />
        </listeners>
      </source>
    </sources>
  </system.diagnostics>

  <system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="serviceDiscoverableBehavior" type="Masieri.ServiceModel.WSDiscovery.Behaviors.DiscoveryBehaviorSection, Masieri.ServiceModel.WSDiscovery, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
      </behaviorExtensions>
    </extensions>
    <services>
      <service behaviorConfiguration="serviceDiscoverable" name="ServiceTest.ServiceInstance">
        <endpoint address="ServiceSample" binding="customBinding" bindingConfiguration="wsHttp"
          contract="ServiceTest.IServiceSample" />
        <endpoint address="ServiceSample2" binding="customBinding" bindingConfiguration="wsHttp"
          contract="ServiceTest.IServiceSample2" />
        <endpoint address="mex" binding="mexHttpBinding" name="HTTPEventAgentMex"
          contract="IMetadataExchange" />
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8080/" />
          </baseAddresses>
        </host>
      </service>
    </services>
    
    <behaviors>
      <serviceBehaviors>
        <behavior name="serviceDiscoverable">
          <serviceMetadata httpGetEnabled="true" httpGetUrl="http://localhost:8080/Mex" />
          <serviceDiscoverableBehavior scopesMatchBy="http://schemas.xmlsoap.org/ws/2005/04/discovery/rfc2396">
            <scopes>
              <add url="http://myscope.tempuri.org/"/>
            </scopes>
          </serviceDiscoverableBehavior>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="wsHttp">
          <textMessageEncoding messageVersion="Soap12WSAddressing10" writeEncoding="utf-8">
            <readerQuotas maxStringContentLength="100000"/>
          </textMessageEncoding>
          <httpTransport/>
        </binding>
      </customBinding>
    </bindings>
      <diagnostics>
      <messageLogging
           logEntireMessage="false"
           logMalformedMessages="false"
           logMessagesAtServiceLevel="false"
           logMessagesAtTransportLevel="false"
           maxMessagesToLog="3000"
           maxSizeOfMessageToLog="2000"/>
    </diagnostics>
  </system.serviceModel>
</configuration>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
Italy Italy
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions