I know there are tutorials out there regarding WCF callbacks and events, but I'm having trouble getting them to actually work, or they're too complex. I'm a real beginner, so I would love to hear if anyone knows of any solid beginner tutorials that are aimed to what I'm trying to specifically figure out at the moment. Please forgive me if I use the wrong terminology (and please correct me), like I said I'm a beginner.
The Problem:
It might look more complicated than it really is. Basically what I'm trying to accomplish is:
What I Can Do:
I can set up the connection, but my service is limited to standalone functions. The client can make "queries", but is limited to remote function calling (such as "add", where all parameters are passed with the function and the processing is done internally).
What I'm Trying To Figure Out:
TLDR:
Host : Service <-> Client. Is there a way to push data (simply an int) to the client without the client calling any functions (no polling or queries)? Is there a way to have the WCF service access variables stored in instance of the host application without using static members? Can this be accomplished in a simple way?
Thanks for your help and time, I know I wrote a book. If anyone knows of any nice tutorials, please point me to them. But PLEASE - Don't point me to the Add(int x, int y) example where the client just calls add on the host and returns the result - I've already done this a few times over and it's not helping me grasp the real functionality of WCF. I'm really not trying to accomplish anything serious at this point, I'm really trying to keep it simple so I can learn what WCF can do, and I'm not finding the documentation to be very helpful. Thanks again everybody.
With the service running, right click the project that will contain the WCF client proxy and select Add > Service Reference. In the Add Service Reference Dialog, type in the URL to the service you want to call and click the Go button. The dialog will display a list of services available at the address you specify.
Abstract: In WCF, callback is used to implement PUSH mechanism, so that delayed or long running operation results can be automatically pushed back to the client application. WCF actively supports callback to its client, over the instance context established.
To consume the WCF service methods from JavaScript, we need to expose them as the RESTful service methods that accept and return the data in either JSON or XML formats. This helps developers to consume the WCF services as easily as the REST services, and use them with the jQuery $.
Generally WCF is used in a request reply way, where clients make requests; and server replies. What you want to achieve is a "push and pull" service; or in Microsoft terms a duplex service.
In duplex services clients just connect to a service and service registers them into some internal list. And whenever an event(or something else) arises, it sends a message to the registered clients. The key terminology for WCF in the context of your question is "duplex services"(you may google it find many results). You may refer to the following tutorials;msdn or codeproject
For the second part of your question, the answer is yes. But this is not that simple. You need to write some "wcf behaviors", for instance an IInstanceProvider
may help you. For all requests, you may just create the service instance yourself, with desired parameters injected into the service instance.
Referring to the following may help: stackoverflow or msdn.
The question is a bit broad thus I am not 100% sure whether this is a direct answer. But at least using the keywords provided you may find the right direction.
Have you tried this article yet? http://msdn.microsoft.com/en-us/magazine/cc163537.aspx#S6. I thought it was a decent explanation on callbacks. It discusses a publish/subscribe framework which is a solution to your "no polling or queries" requirement.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With