Reputation: 320
I am on my reading week, and due to Family Day (national holiday) my web services class was cancelled last Monday. Unfortunately the teacher still assigned a project due before we get to see him again.
I am supposed to make a WCF service with a windows form client.
I want my client to be able to update some strings in my StockService.svc.cs class. The only problem is, it doesn't retain the data. I know this is related to the session, and that you need to specify the type of session or something in the service class.
What is the keyword I type in so the session will last until the client is closed, so that any values that are changed will be retained for the session?
I found:
[WebMethod(EnableSession=true)]
But since my teacher hasn't covered this in the lab yet, I don't know how to use it. It gives an error :
Error 1 Attribute 'WebMethod' is not valid on this declaration type. It is only valid on 'method' declarations.
Any help would be appreciated. (Note: Although I emailed the teacher it has been 3 days and I don't want to be doing this last minute!)
Upvotes: 0
Views: 1452
Reputation: 1008
The attribute you're trying to use is for XML Web Services only. I recommend you this article that talks about WCF Sessions. Sessions in WCF Services are not the same as in asp.net. One solution for your problem could be using a static variable to store the inserted values. I made some tests here and it works perfectly
Upvotes: 2