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

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.

Related

How to move BizTalk EAI services from on premises to Logic Apps which is using TCP/IP custom adaptors(designed by codeplex)

We have BizTalk EAI application which received request and send response to client using sokect switching (TCP/IP adaptors designed by codeplex) .
We need help to move EAI application from in premises to Logic Apps. Could anyone assist us to implement socket switching (TCP/IP adaptors/connectors or triggers) to receive request and sending response back to client
Thanks
Unfortunately, this is a notable gap in the available Connectors right now.
You best option is to stand up a Azure VM with a BizTalk Server instance to host this Adapter. You can connect it to the Logic Apps through Service Bus, Logic App Adapter or such.

How to send email using SharePoint's Silverlight Client Object Model and avoid creating a web service?

I am developing a Silverlight application that is supposed to send an email to a particular SharePoint user. I need two things:
I need to get the email address associated with the SharePoint user
BUT MUCH MORE IMPORTANTLY, I need to be able to send the actual email.
Since there is no System.Net.Mail class for Silverlight, it appears that I am condemned to create my own web service that is going to be in charge of sending emails. I am trying to avoid this, and I was wondering if there is a way to send an email to the SharePoint user using SharePoint's Silverlight Client Object Model? Thanks for clarification!
You could have a webpage that the user hits (possibly silently) rather than a web service, but at some point you're going to need to send a request that gets you to the server because this isn't an operation that can be done via the client.

How do I check the connection status of my WCF service

I am currently developing a WCF publish subscribe service on a winform app. How do I code it in such a way that whenever a client subscribes to my service, I would be able to display a message in my textbox saying, "1 client has connected/disconnected to/from the service"
As marc said, clients don't maintain connections to WCF services, but you can monitor imaginary connections by having the clients regularly call an "I'm here" method on the service while they are "connected", and when they stop calling it, you consider them to be "disconnected". I've found this strategy to work well for a distributed processing application when I wanted to keep track of how many agents were available to do work.
Have a look at the Microsoft Duplex Services (WCF)
Duplex Services

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.

What are typical server to client communication patterns?

What are the usual patterns for bidirectional communication between a client and a server in a wlan environment. How is it possible for the server to push data to a mobile client over wlan after a connection has been established.
Lets say I have a webservice running on a server and the moblie cients in the wlan can use this webservice. Now the question is how can the server invoke methods at the client, or directly send data to the client. How is this handled usually?
I would apriciate some links to read about this topic.
Is this a common problem or is it not that easy to solve?
Cheers
HTTP server push (also known as HTTP streaming) is a mechanism for sending data from a web server to a web browser. HTTP server push can be achieved through several mechanisms.
More at http://en.wikipedia.org/wiki/Push_technology#HTTP_server_push
In web development, Comet is a neologism to describe a web application model in which a long-held HTTP request allows a web server to push data to a browser, without the browser explicitly requesting it. Comet is an umbrella term for multiple techniques for achieving this interaction. All these methods rely on features included by default in browsers, such as JavaScript, rather than on non-default plugins.
More at http://en.wikipedia.org/wiki/Comet_(programming)
Also there is a recent IETF draft on
Best Practices for the Use of Long Polling and Streaming in Bidirectional HTTP
https://datatracker.ietf.org/doc/html/draft-loreto-http-bidirectional-01

Resources