may be below video will help you to create a WCF service. Once create simple WCF service after that add your code.
Maintain a Dictionary with WCF RESTful Service
-
15-07-2023 - |
Question
I need to write a RESTful WCF service that maintains a dictionary (or any other suitable data structure) with userId:userData as key:value pairs. For that I first need to implement an interface for getting and setting userData (the specific configuration is enclosed):
GetConfiguration() : returns default config when user hasn’t set a config yet
GetConfiguration(string id)
SetConfiguration(string id, Configuration configurationSchema)
Then I'll need to write a service that implements this interface.
As a newbie in WCF I'm not sure how to do it. I tried to look for relevant references but didn't found any.
Appreciate any help/relevant references, Thanks !
The userData object:
public class ConfigurationSchema
{
public string MobileNumber { get; set; }
public List<string> Habits { get; set; }
public ConfigurationSchema(string mobileNumber, List<string> habits)
{
this.MobileNumber = mobileNumber;
this.Habits = habits;
}
}
Solution
OTHER TIPS
If you did not find references to help you, I'd suggest you learn to google before you tackle programming problems. It's worth it. For your problem:
- Open Visual Studio
- Chose WCF project
- Replace example complex data structure by your own class
- Rename methods
- Rename interface
- Press F5