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. And for now I am starting to create a WCF service for it.
This is a sample scenario of what I meant,
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.
so for the operationcontract of the service, what type of methods should i put in in order for me to receive the posting?
e.g.
[OperationContract]
bool receivePosting(int n);
I’m not quite clear as to which direction you want to communicate:
or:
I put “server” in quotes because in WCF world, that’s a term being used for a specific role.
Assuming the first option, you need to do this:
your Winforms app needs to be the WCF server – e.g. it needs to define a service contract, operation contract and data contract – and implement those
your “posting server” would be the WCF client in this case; whenever a posting is received/stored, then you would call the WCF service in your Winforms app to send a notification (so really, in this setup, your roles are reserved – the Winforms app is the WCF server)
As for the operation contract – what does your Winforms app need to know about the new posting? Just the fact a new posting has been received? The whole contents of the posting, or just parts of it??
In any case, you need to define a method on your WCF service that the “posting server” can call and pass all relevant info to the Winforms WCF Server – you don’t want to have to make two or more calls just for one notification.
So you Service Contract might be:
and your
Postingclass would be the data contract:Whatever you need to send between those two parties – define it in your data contract which is the argument to your service call