Click here to Skip to main content
15,892,839 members
Articles / Programming Languages / C# 4.0

Push Messages in RESTful WCF Web Application with Comet Approach

Rate me:
Please Sign up or sign in to vote.
4.91/5 (37 votes)
25 Apr 2011CPOL9 min read 112.1K   4.7K   99  
The article discusses a RESTful WCF based mechanism for server-to-client asynchronous (Push) notifications in web applications. Execution of WCF service notification method is suspended until either server event or timeout lapse.
<?xml version="1.0"?>
<configuration>

  <system.serviceModel>
    
    <bindings>
      <webHttpBinding>
        <binding name="webHttpBinding_Service"
          closeTimeout="00:25:00" openTimeout="00:01:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
          transferMode="Buffered"
          bypassProxyOnLocal="false"
          >
          <security mode="None" />
        </binding>
      </webHttpBinding>
    </bindings>

    <behaviors>
      <endpointBehaviors>
        <behavior name="EndpointRestBehavior">
          <webHttp />
        </behavior>
      </endpointBehaviors>
    </behaviors>
    
    <services>
      <service name="RestService.FormSvc">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8700/"/>
          </baseAddresses>
        </host>
        
        <!-- Service Endpoints -->       
        <endpoint address="FormSvc" 
                  contract="RestService.IFormSvc" 
                  binding="webHttpBinding" 
                  behaviorConfiguration="EndpointRestBehavior"
                  bindingConfiguration="webHttpBinding_Service" />
      </service>

      <service name="CometSvcLib.CometSvc">
        <host>
          <baseAddresses>
            <add baseAddress="http://localhost:8700/CometSvc"/>
          </baseAddresses>
        </host>
        
        <!-- Service Endpoints -->
        <endpoint address=""
                  contract="CometSvcLib.ICometSvc"
                  binding="webHttpBinding"
                  behaviorConfiguration="EndpointRestBehavior"
                  bindingConfiguration="webHttpBinding_Service" />
      </service>
    </services>
  </system.serviceModel>

  <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>
</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 (Senior)
Israel Israel


  • Nov 2010: Code Project Contests - Windows Azure Apps - Winner
  • Feb 2011: Code Project Contests - Windows Azure Apps - Grand Prize Winner



Comments and Discussions