What operation contract can I put for my WCF service?
-
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);
-
Answer:
I'm not quite clear as to which direction you want to communicate: your "server" needs to notify the Winforms app of a new posting that's been saved? or: your Winforms app asks the "server" about new postings?? 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: [ServiceContract] public interface IPostingService { [OperationContract] void NotifyAboutPosting(Posting post); } and your Posting class would be the data contract: [DataContract] public class Posting { [DataMember] public int ID { get; set; } [DataMember] public string Description { get; set; } [DataMember] public DateTime PostingTimestamp { get; set; } } Whatever you need to send between those two parties - define it in your data contract which is the argument to your service call
Thomas at Stack Overflow Visit the source
Related Q & A:
- How can I put games (if you can) into my TI-83 Plus?Best solution by answers.yahoo.com
- What exactly are podcasts and how can I put them on my iPod?Best solution by Yahoo! Answers
- Where can I find an Apple authorized service center in pune, India?Best solution by Yahoo! Answers
- What can i put in my hand luggage?Best solution by Yahoo! Answers
- What else can I put with my betta?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.