How do I display a message in my WCF Application? - winforms

I am currently developing a WCF Publish Subscribe service on a windows form application. How do I code it such that whenever the publisher publish something, my WCF Service would display a message in the winforms app saying :
Post has been sent to all subscribers at [Current Time]
Do I have to create another callback channel? Or just another service contract.
Thanks!!

I am assuming that you are publishing events by sending WCF calls from your windows forms application.
In this case you can do this with events.
When your WCF service sends the message, it also rasises an event. In the shell of your windows application you catch the event and display a message box.

Related

WCF and multiple clients

I have a WCF hosted in IIS, at the same time I have two clients, a WPF application and a Window Phone Application. My program work in the way that, the Window Phone Application will send a Message to the WCF and then the WCF will send it to the WPF application. How can I achieve it?
I have take a look at callback, but I believe what it does is to return a message back to the Window Phone Application after the Phone Application consume the WCF service. But what I want my program to do is to send the Msg from the Phone App to the WPF application instead.
please guide me. Thank you!
I would probably do it this way:
inside the WPF application, host a second WCF service to receive that message - your WPF application becomes a WCF server
when a message comes in from the Windows Phone into your WCF service in IIS, that service class then becomes a WCF client to the WPF app and send that message onwards to the other WCF service
Callback won't work - since callback can only call back to the original caller (your Windows Phone, here) and that's not what you want.

Should I use duplex WCF service or a regular WCF service?

I am currently developing a C# Windows Form Application that I intend to let it interact with a server. The server will receive posting from a mobile application that I have developed and whenever a posting is received, my Windows Form Application should be notified and give me a notification.
E.g. My mobile application sends an posting over to my server. Once my server receives the message, my windows form application should display a new notification showing the content of the message received and updates the UI accordingly.
In this type of scenario, it is better to use duplex WCF service or the just the regular WCF service?
If duplex, mind explaining why do I need to use duplex service? Thanks!
A duplex service is a service where two channels are created.
The first channel is the ordinary client -> server channel using your service contract. This is what you'll find in every WCF service, and is how your client can send a request to the service and it can respond.
The second channel is a server -> client channel using a different service contract that you define. This second channel is how the server can send messages to the client without the client requesting them.
In your scenario, you seem to indicate that an event taking place on the server should send a message to your client. If this is the case, then yes, you need a duplex service so that the second channel exists, which allows the server to notify your client without the client initiating a request.
Working on the assumption that your Windows app and your server are one the same domain I would suggest you use a publish/subscribe pattern for this type of interaction. You could use something along the lines of the IDesign sample which is available on their website. Essentially your Windows app is subscribing to events which are generated by your mobile application sending a posting to your server. Your publisher will then push the event to your Windows application.
To accomplish this your connection to the server/publisher needs to be always open. This is best achieved with tcpBinding as it is bi-directional and allows you to set high timeouts (effectively infinity).
If you cannot use TCP then your job has become a little harder. Using a duplex channel is a little problematic because you have to monitor the channel as well, because neither side will notifiy the other if the channel closes. You will only find out when you try to use it. This can still happen with the TCP connection of course but its a bit more stable that using http.
The other alternative is to use MSMQ binding. This will guarantee the delivery of your message because you are interacting via MSMQ rather than a communication channel such as http or tcp. In this instance you wouldn't even need the pub/sub framework, you could just have the service that receives your mobile posting send on a message to the queue, which your Windows application is monitoring. The upside to using the framework is that you can have multiple applications listening for the same event.
HTH.

How does my WCF Service communicates with my Winforms App Client?

I am currently developing a C# Windows Form Application that I intend to let it interact with a server. The server will receive posting from a mobile application that I have developed and whenever a posting is received, my Windows Form Application should be notified and give me a notification.
E.g. My mobile application sends an message over to my server. Once my server receives the message, my windows form application should display a new notification showing the content of the message received
The WCF Service has been done up in a seperate project file as I need the client to connect to the Service instead of hosting the service in my client project file. What I would like to ask is how does the service communicates directly with my winform app? Such as updating the UI of my winform app everytime a alert is received.
It sounds like you are looking for a Publish Subscribe Framework. This will have your windows forms application act as a client to the server to subscribe for notifications, then act as a server to receive notifications as the mobile application posts come in.

Inter Process Communication between Silverlight OOB & Non-Silverlight Desktop Application

I have a Silverlight OOB Application installed, and I want to send messages to this application from any non-silverlight desktop application (Let this application be any WinForms, or Console Application). How can I achieve this?
For anyone looking over this old thread, you can create a duplex wcf service using http polling. Call the service from any application, the silverlight client can be registered as a callback and then receive messages directly from the server.
More reading:
http://msdn.microsoft.com/en-us/library/cc645027(v=vs.95).aspx

silverlight app realtime update design

I have a winform app, which takes live image from an ip camera, and detect vehicle license plate number from the image. Now i want to make a silverlight app which can connect to my winform app or some kind of service app, and the silverlight app gets updated whenever a new license plate number is detected, what service/architect should i use to make this possible?
Thanks for you advice.
Your going to need the following...
An IIS server that exposes a WCF service. Your Silverlight application can be running in any browser in any location and from time to time it needs to poll for new data by making a request to the WCF service asking for the latest updates. Your WinForm application can send new data to the WCF service whenever it has new data. The WCF service running in IIS acts as the buffer that caches the incoming updates from your WinForms application that passes it back to any number of Silverlight clients that request the latest data.

Resources