WCF Closing a connection/Releasing resources
I've recently converted my ASMX service to WCF to take advantage of Sessions. 

I've reviewed some of the Sessions tutorials on MSDN but still not sure I have a good setup in my code. as of now it works, but I'm not really sure why.

I got 

       [ServiceContract
        (SessionMode = SessionMode.Required,
         Namespace = "http://smartshopservice.org")]

Then I have 

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
        public class SmartShopService : SmartShopInterface
        {
            private static Shopper sh = new Shopper();
            private List<aaa> data = new List<aaa>();

The first part of my question is whether Shopper is my "global" variables. I want it to always be there, while everything else such as "data" is instanciated per session. I've also setup WebConfig appropiately. Is there anything else I need to do?

My second question is how to close a session, and then flush all these variables? My Client right now is a WebClient, it is communicating like this:

    static GarfieldService.SmartShopInterfaceClient service = new GarfieldService.SmartShopInterfaceClient();

It seems to work, and I have onbody="" of the ASP.NET page to call a function that looks like this:

 

    [WebMethod]
            public static bool Connect() {
                try {
                    if (service.State == System.ServiceModel.CommunicationState.Closed) {
                        service.Open();
                        return true;
                    }
                    else if (service.State == System.ServiceModel.CommunicationState.Created) {
                        service.Open();
                        return true;
                    }
                }
                catch {}
                return false;
            }

So I can connect, but how do I disconnect or close a session?

WCF Closing a connection/Releasing resources
===

I've recently converted my ASMX service to WCF to take advantage of Sessions. 

I've reviewed some of the Sessions tutorials on MSDN but still not sure I have a good setup in my code. as of now it works, but I'm not really sure why.

I got 

       [ServiceContract
        (SessionMode = SessionMode.Required,
         Namespace = "http://smartshopservice.org")]

Then I have 

    [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
        public class SmartShopService : SmartShopInterface
        {
            private static Shopper sh = new Shopper();
            private List<aaa> data = new List<aaa>();

The first part of my question is whether Shopper is my "global" variables. I want it to always be there, while everything else such as "data" is instanciated per session. I've also setup WebConfig appropiately. Is there anything else I need to do?

My second question is how to close a session, and then flush all these variables? My Client right now is a WebClient, it is communicating like this:

    static GarfieldService.SmartShopInterfaceClient service = new GarfieldService.SmartShopInterfaceClient();

It seems to work, and I have onbody="" of the ASP.NET page to call a function that looks like this:

 

    [WebMethod]
            public static bool Connect() {
                try {
                    if (service.State == System.ServiceModel.CommunicationState.Closed) {
                        service.Open();
                        return true;
                    }
                    else if (service.State == System.ServiceModel.CommunicationState.Created) {
                        service.Open();
                        return true;
                    }
                }
                catch {}
                return false;
            }

So I can connect, but how do I disconnect or close a session?
