Submitting data to a website from a WCF service

I have the following setting

  • A jQuery site (not exactly one page, but not far from it) that uses
  • ASP.NET MVC website as a backend that connects (via net.tcp or net.pipe) to
  • A stand-alone WCF service that manages and connects to
  • Lots of high latency external services.

Therefore, when the client clicks the button, a request is sent to MVC, which redirects it to WCF, which aggregates it from external services, and everything is fine and dandy.

The problem with which I do not seem to be enveloping is communication in a different way, i.e. when one of the external services is disabled, the easiest and most elegant way to inform the client (browser)?

This means that the service must somehow inform the mvc site, which must somehow tell the client that the external service is disabled.

Additionally: the external service will have high availability, so the "go offline" scenario will be rarely used, and, accordingly, I am looking for a solution that does not conduct an extensive survey of the server.

+7
source share
5 answers

I am working on a similar architecture and plan to use SignalR to push updates from WCF (sometimes directly, sometimes through the Azure Service Bus) to a single-page jQuery-enabled application. However, I have not implemented this yet, so there may be some problems that I have not considered.

From your documents:

Pushing data from the server to the client (and not just the browser clients) has always been a difficult problem. SignalR makes it dead easy and handles all the heavy lifting for you.

Scott Hansleman has a good blog on this topic: http://www.hanselman.com/blog/AsynchronousScalableWebApplicationsWithRealtimePersistentLongrunningConnectionsWithSignalR.aspx

+4
source

You can use exception exceptions to return exception data to the client.

I prefer to have the IsSuccessful flag in my returned contracts and only throw exceptions in case of a critical error.

Here is a very simple example of a response contract with the IsSuccessful flag.

 [DataContract] public class MyResponse { [DataMember] public bool IsSuccessful { get { return Message == null || !Messages.Any(); } set { } } [DataMember] public List<string> Messages { get; set; } } 

Messages can be complex types if you need to provide more detailed information. DataContract and DataMember can be MessageContract and MessageBodyMember if it suits your architecture better.

+1
source

It seems to me that you will need to implement some type in the polling service to check these external services for their availability.

+1
source

A typical scenario with WCF and a browser is a request / response template. The browser executes the request and the service responds.

You can force the browser to periodically poll a service that is looking for status.

0
source

Discovery Namespace has a feature that allows the WCF service to send discovery messages. If you have a scheduled break, the AnnouncementClient class has methods for publishing offline / online messages.

To set up a custom message for your users, you need to listen to these messages. The class that implements this is AnnouncementService . It has events for processing Offline and Online messages.

0
source

All Articles