WCF and multiple clients - wpf

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.

Related

WCF client hosted in a windows service with a WPF UI

I have now a WCF service that is hosted inside a WPF application. It's running in a WCF server-client scenario where the client can call the server as well (duplex communications).
I would like to host the WCF client in a windows service, but I'd like to keep the WPF UI because of the functionality it provides when making calls back to the server (e.g. request information). I know that windows services don't have UI, but in this case I need it.
What best way is there to communicate between the WPF application and the windows service? (something better than sockets maybe?)
A scenario where this is useful would be something like:
from the WPF application I can choose what kind of information would be required from the WCF service acting as server,
this "command" would be sent to the windows service hosting the WCF client instance, and
using the the instance making the call to the server and
displaying the information in the WPF application via the WCF client service hosted by the windows service.
Thanks,
Adrian
Since the service is already running as WCF, how about exposing some extra "admin" methods on the WCF interface and have the WPF application interact with the service through those?
You'd have to put in a security layer to make sure only the legitimate user could call those new methods, but this solution might be the least work since the WCF infrastructure is already in place.

How do I display a message in my WCF Application?

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.

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

Intercommunication between two .Net Applications using WCF service

I have a WPF application. On the same machine I have a console application.From this console application i want to see if user has successfully logged in and a particular page is open in WPF application. If this is the case then i want to show a popup in WPF application.
To implement this I Thought of using WCF services. I have got 2 options. Create a seperate WCF service and run it as soon as WPF application runs and then ask the client application to communicate.
Second option is to host the WCF service inside the WPF application and run it when WPF application starts.
I am not able to decide on which way to choose. If anyone of u has implemented this kind of setup before,please share your ideas.
Because you want to see if a page is open in the WPF application, I'd suggest hosting the WCF service in the WPF application (i.e., using the ServicHost class). Then have the console application consume the service to determine the page status as per your requirement.
Also, use the NetNamedPipeBinding (http://msdn.microsoft.com/en-us/library/system.servicemodel.netnamedpipebinding.aspx).

Resources