Notify client application from wcf service - wpf

I have a wpf application which is running on diffrunt clients pc which get data from a wcf web service.
Now when update some data from web service I need to notify that to perticar client.
So I need to push data from web service to client
How can I do this?
Thanks in Advance.

You have to Use Duplex service in WCF
Sample Here

As mentioned by those above, a duplex service in WCF would work for you. There are alternatives though that achieve a similar function, but may not fulfill your needs.
SignalR
WebSockets
and server polling (you can google this for many various articles explaining it).

You can implement the Observer design pattern.
For my surprise, Wikipedia gives a very good definition on the first paragraph about this pattern.
http://en.wikipedia.org/wiki/Observer_pattern
Hope this works for you.

Related

Send simple data from wp7 to winforms application

I want to send simple data (geolocation data to be precise) from Windows Phone 7 application to a windows forms application and use it, as I'm a total beginner in this field I don't know which tools to use.
I searched about wcf services and tested this method but there's some issues: the data is sent from the phone application but isn't sent to the winforms application (guess something is missing)
If your know how to do this in a quick way, or have good tutorials I'll be thankful.
EDIT
I found this tutorial, it show how to connect directly wp7 application and desktop application without using sockets neither wcf service, I'm wondering if it is really works if the application isn't in localhost.
the like for the tutorial: wp7 tutorial
I had a similar problem and so I created a REST/JSON WCF service hosted in IIS with AppHarbor to provide the data. There's hundreds of ways to do it (Ruby/Heroku, etc..), but that particular one fits well within the Microsoft stack. I also needed to share route data and I used the WCF service to wrap the BingMaps services so that route computations are cached and shared. Considering that I had already created a local model, moving it out of my phone project into a service took less than a few hours (including the usual config hiccups, and forgetting to add the appharbor user to my bitbucket repo).
Consuming the service from WinForms (or any client) shouldn't be an issue as the service knows nothing about the client implementation.
Here's a tutorial from code project. REST WCF Service with JSON
I think you would need to implement some sort of server side solution which you could upload to on your Windows Phone and download from on your Windows Form application. This could be achieved using a WCF service which was connected to a server side database.
Another option would be to use sockets and communicate directly with your WinForms application. Check this tutorial on how to use basic sockets on WP7.

Define WCF Endpointbehaviors in Silverlight project to put message on a service bus for appFabric

I am attempting to send statuses to appFabric via a service bus from a silverlight application. Everything is tested and working except for the Silverlight application itself which does not appear to have a way to define endpointBehaviors. Endpointbehaviors are needed to provide a sharedSecret when communicating on a servicebus. Does anyone know how to define the issuer secret in silverlight?
This is not possible. So I am going to have to use another service to forward requests.

Call a WCF from only my silverlight application

I have a WCF.
I have a silverlight application.
I do not want anyone to be able to call the WCF except the Silverlight application.
I do not want to install any certificates on the client.
I do not want to hit any databases.
What would typically be the best way to do something like this?
You can address this using a cross domain policy file. Silverlight cannot connect to WCF services hosted on secondary domains without the implementation of this policy file.
Here are two links to get you in the right direction
http://msdn.microsoft.com/en-us/library/cc197955%28v=vs.95%29.aspx
Tim Heuer has a good writeup on the implementation of this file as well.
http://timheuer.com/blog/archive/2008/04/06/silverlight-cross-domain-policy-file-snippet-intellisense.aspx
To prevent a WCF services from being accessed by other applications you will need to implement authentication of some sort Here is a related post

Generate a WCF proxy for Silverlight without adding the ASync pattern to the WCF service without hosting the service

I got a coding scenario I can't seem to fix.
I got a synchronous WCF service and I want to simulate the Add Service Reference (slsvcutil.exe) but without hosting the WCF service. Is this possible?
I want use slsvcutil to generate the client from a wsdl file but it doesn't want to work because it needs an endpoint. Is it possible to generate a WCF proxy for Silverlight without hosting the service and without editting the WCF service by making all calls Asynchronous?
Is the reason you want to generate the proxies without hosting because you don't want to "add the asynch pattern"?
You don't have to edit the WCF service to make it callable asynchronusly, the asynch is all handled by the client not the server.
Take a look at this tutorial and you'll see that the service code doesn't mention asynch at all. http://www.dotnetcurry.com/ShowArticle.aspx?ID=228
Practically everything in Silverlight is asynchronus and for good reason. It's that way so that the end user doesn't experience blocked UI threads while the app goes off to fetch data.

Silverlight - Client Verification

I have a Silverlight application that needs to retrieve some data from my database. This data is sensitive. Because of this, I only want my Silverlight application to be able to access the data. How do I ensure that only my applications can access the services that expose this data? Is there a way that I can validate a client attempting to retrieve the data?
Thank you!
These might be of interest:
Using ASP.NET Secure Services and Applications Services
Build Line-Of-Business Enterprise Apps With Silverlight, Part 2
MS Whitepaper: Security Guidance for Writing and Deploying Silverlight Applications
Well, everything your SL application does could be spoofed. So direct answer is NO, you cannot ensure that only your application will access to the data.
But there are number of options. For example you can implement authorization and then authenticate your user. In this way you can ensure that only users you trust access to the data.
Another option is to make spoofing harder. For example you can include sort of "secrete" token to all your requests. So other application will need to steal this token. This harder to achieve.
I think this question is more pertaining into implementing a web service or wcf service with authentication and authorization. If your service takes care of it, then you can be ensured about your data. Your silvelight app is just calling the service.
Whoever download the xap can decompress and reverse engineer your code, so your best bet is to build a web service as others suggested. Silverlight Ria ships with a full blown authentication membership that you can leverage.

Resources