I have been reading a lot of forums regarding the use of WCF in web, most specifically, this topic: WCF with Flash tutorial, but I am really confused.
I have an existing feed server that is using WCF service. It is, with no problems, supplying real-time information to its windows applications clients. What i would like to do is to have a web application to subscribe to the feeds that i am supplying to the windows application clients. With the forum that i have read (the one i have indicated), it seems like it will be a request reply method. And i think, using that, i wouldn't be able to achieve the real-time transfer of feeds for it.
I would like to know if there is an equivalent for the callback function in web development.
I think Duplex service meets your requirement.
Please use Duplex type of WCF services.
A duplex service contract is a message exchange pattern in which both endpoints can send messages to the other independently. A duplex service, therefore, can send messages back to the client endpoint, providing event-like behavior. Duplex communication occurs when a client connects to a service and provides the service with a channel on which the service can send messages back to the client. Note that the event-like behavior of duplex services only works within a session.
Links:
http://msdn.microsoft.com/en-us/library/ms731064.aspx
http://www.c-sharpcorner.com/uploadfile/dhananjaycoder/a-simple-duplex-service-in-wcf/
http://msdn.microsoft.com/en-us/library/ms731935.aspx
You can also use web sockets which is new in WCF 4.5. Below are web socket WCF links:
http://msdn.microsoft.com/en-us/library/hh674271.aspx
Related
Does MassTransit support WCF? I searched their website but couldn't find any examples on whether you can or how to create a WCF client/service using MassTransit. If it can be done, can someone please provide an example? a tutorial?
You can use WCF to create a public interface that bridges an external service to an internal message-based application, but WCF is not a supported transport for durable messaging.
This would be useful in a case where your internal system might become overloaded by an external service, and you need to buffer the ingestion of data via a SOAP-based WCF service. The WCF endpoint would send messages to a command queue to process the information asynchronously, preventing timeouts from being pushed back to the calling service.
Well, I am thinking about creating a web application with C# and asp.net mvc 4. The idea is create an asp.net web application that can be use in any browser, so I can use my application anywhere and any computer.
But in the communication, can I use WCF or the communication is over HTTP and I can't choose other transport?
I mean that if WCF is only to communicate two desktop/mobile applications or it could be use for web applications too?
In a web application is possible to have a duplex communication?
You can use HTTP bindings in WCF if you want to use SOAP. Otherwise you may want to look into WebApi which provides a more natural abstraction over HTTP. For duplex communication over HTTP you can consider SignalR.
can I use WCF
Yes, WCF can be hosted in an asp.net application.
Duplex Communication cant induced easily in Client-server model where system is working in disconnected fashion.
What happen when when your client(browser) want some data.
1) Request comes to server
2) Server ask to WCF duplex service and forgot to wait for response as it is duplex in nature.
3) WCF duplex respond to Server with data
4) Now server can process that data either by saving or logging to Database but doesn't know who was the client that asked for and how to intimate them.
So what is the solution
User SignalR with Some weird coding.
OR
Call WCF service directly from Browser by jquery $.ajax call So your browser directly will have response from WCF service.
I'm trying to build a http listener (webservice) with wcf. This listener is part of a bigger desktop application. This desktop application also invokes the http listener.
When the listener receives data it should be passed to the desktop application. I tried to build an httpbinding service and use the callback mechanism
[OperationContract(IsOneWay = true)]
void OnDataReceived(Data data);
The problem is that I need wsDualhttpbinding because of the callback.
Do I really need to use the dualhttp to send data from one .NET app to another or am I missing something?
Thanks
Yes you need dual or duplex communication. HTTP by its very nature is a single direction protocol. The client has to invoke the server. The server has no way to talk to the client with out that.
Your problem is you have an event source which is exposed as a WCF service. The only way to for the service to send events to it's clients in real time is via a full duplex connection which means using either duathttp or dualtcp bindings.
However, using duplex bindings is complex at best. It would be simpler to allow the client to subscribe to the service and to then receive messages when events happen which the client is interested in.
This is much simpler than duplex bindings because there's no actual connection between client and service, only asynchronous messages.
While WCF provides bindings for msmq transport, it does not provide a binding with this kind of pub-sub support, so you can either code for this or you can use an open source messaging bus like NServiceBus.
If you are using a callback mechanism, as opposed to a polling mechanism, then yes, you need Dual binding as the WCF services needs to be able to both Send and Receive messages (as opposed to Receive and return responses)
I have a Wcf Data service exposing entities from Ado.net entity framework. I would like to know whethere I can use msmq messaging with my data service.
After searching on internet i could find links for using with a wcf service only.
Please provide some links with a sample.
No you cannot.
WCF Data Services is using HTTP/REST only - it cannot be used over any other protocol or with any other binding.
MSMQ is only available when you use "regular" WCF services that use the SOAP protocol for communication - that can be routed over different transport media.
REST is very tightly and intimately tied to HTTP only.
WCF supports MSMQ as a transport protocol and provides the standard MSMQ binding. Here is a link to MSDN article devoted to using MSMQ in a WCF application:
How to: Exchange Messages with WCF Endpoints and Message Queuing Applications
I'd like to write a program where you can have 2 clients that talk to each other in realtime. I've been looking into WCF services and Duplex messaging, data contracts etc but now I'm confused.
Basically I see it as:
[Client] --- msg --> [Server] --- msg --> [Client] and vica versa.
The server will just act as the messenger.
Could you please point me in the right direction? I'd like to use WPF for the client apps.
Check out the WCF peer-to-peer programming paradigm. It will be extended in WCF 4 (with .NET 4 - due out April 12, 2010) by allowing dynamic discovery (and article here) of other clients on your network.
This should help get you going: WCF / WPF Chat Application
Perhaps Windows Azure Service Bus (which uses WCF) might be worth a look?
Service bus can effectively be used as a message bus, which is one way to implement what you are describing.
I can think of two scenarios
The clients are the only ones that start a request, to send they push messages and to receive they request periodically for new messages. The main advantage of this architecture is that it is more firewall-proof.
The clients are also servers that receive messages relayed by the central server. The main advantage is that the clients receive updates faster and they save bandwidth.
I wrote program like your sample!!!
but it has one big different: My program have a chat server and a client. clients can chat to others.(with chat server service)
This program use two wcf service for make a connection between client and server.(client call server and send message for it,server get message from client and send for all client have connected to server)I think u used one service and must be use two service(like me) or use Duplex Service.
The sucha barber`s example is too cool(WCF/WPF Chat Application in answer eric). He used duplex services but real problem of this example is "sucah used WPF too and it s expert example for beginners (like me and u)".
If u want i can share my program!!!
seethis