Web services have not any mechanism by which can maintain state. But web services can access asp.net objects like Session, Application and so on if they are inherit from web services bass class.
In this article, I would demonstrate how Session and Application Object can maintain by Web Services. I have created a web form called Session-Application.aspx, which only includes a buttons named. If you click on a button, an event is triggered, and the Web service calls:
Session Object
Session objects store information between HTTP request for a particular user.
Example
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<p>
<asp:Button ID="BtSession" runat="server" Text="Session"
OnClick="BtSession_Click" />
</p>
</div>
</form>
</body>
</html>
C#
protected void BtSession_Click(object sender, EventArgs e)
{
Session["Session"] = "aspxtutorial.com";
MyWebServices WS = new MyWebServices();
Object T = WS.getSessionValue();
Response.Write(T);
}
VB.NET
Protected Sub BtSession_Click(sender As Object, e As EventArgs)
Session("Session") = "aspxtutorial.com"
Dim WS As New MyWebServices()
Dim T As [Object] = WS.getSessionValue()
Response.Write(T)
End Sub
Here is a preview of the Object that will be returned.

Application Object
Application object can be used in situation where we want data to be shared across users globally.
Download
Session-Application.rar (2.36 kb)
See Live Demo