Matthew Layton
Matthew Layton

Reputation: 42229

Listening to a WCF service from a Windows Forms Application

I have been tasked with writing some functionality into my companies web application (written in C# and ASP.NET).

Part of the web application allows customers to raise support tickets via the website. These are posted to the server through a WCF web service.

What the company wants is a mechanism, whereby when a customer raises a support ticket, technicians are notified by a windows forms application that will sit in the task tray and show balloon tips saying there is a new ticket.

The server that hosts the web application (and WCF services) are on different domains to the Technician's machines, and therefore I believe that this mechanism will require some kind of REST service which posts a message to all listening Windows Forms clients.

I've trawled through a lot of articles about REST services, listening to WCF...without much progress!

My questions are:

Upvotes: 0

Views: 1126

Answers (2)

Steven Licht
Steven Licht

Reputation: 770

You can create a DuplexService. ie Specify a CallbackContract by which the technicians will receive notifications. Duplex is a bit none standard though.

    [ServiceContract(Namespace=ServiceContractNamespaces.ServiceContractNamespace,
                 CallbackContract = typeof(ISupportTicketCallback))]
public interface ISupportTicketService
{
           [OperationContract]
           int CreateSupportTicket (SupportTicket supportTicket);
}
public interface ISupportTicketCallback
{
        [OperationContract]
        void SupportTicketCreated(int supportTicketId);
}

Alternatively your WCF Service can publish messages via MSMQ to the technician's application.

In either case, notifications will be event driven. No polling required. Very clean solution:)

Upvotes: 1

Rob Hardy
Rob Hardy

Reputation: 1821

If you already have a WCF service implemented for posting the tickets, then I can't see it being a huge effort to extend the service and add a method for listing tickets.

For performance you can have an overload which accepts a date, allowing you to get all tickets raised after that date. - This means your first request can get all tickets, and future requests with date of last request included will only get new tickets.

Consume the service with the new method from your windows forms application and poll it at regular intervals. Then just pop up your balloon tip when the service returns new tickets.

Upvotes: 1

Related Questions