You know how you add a service reference to your client and then it creates this nice proxy so you could invoke methods on server side? Something like this:
MyServiceClient proxy = new MyServiceClient();
proxy.GetMessage();
I've got a couple of questions about what just happened:
When is the session with the server established? When I added the service reference? When I created the proxy? Or when I invoked the method?
If I will create another
MyServiceClient
instance will it be a singleton copy of the instance we created before(proxy) or it's a new instance entirely?
There is no 'session' by default. A new connection is made when you make a service call and lasts only until the response is received. If you want to group multiple calls (to ensure they use the same instance and in turn enforce processing in sequence) you need to use the SessionMode property on your service contract, which will consequently affect how the proxy client behaves.