I am trying to implement webservice authentication using SOAP Header. I know how to achieve this. i have a requirement about how to provice single authentication which applied to all the methoads of webservice.
Example :
public class Service:System.Web.Services.WebService
{
public AuthSoapHd spAuthenticationHeader;
public Service()
{
}
public class AuthSoapHd: SoapHeader
{
public string strUserName;
public string strPassword;
}
[WebMethod,SoapHeader("spAuthenticationHeader")]
public string HelloWorld()
{
if (spAuthenticationHeader.strUserName =="TestUser" &&
spAuthenticationHeader.strPassword =="TestPassword")
{
return "User Name : " +spAuthenticationHeader.strUserName + " and " +
"Password : " +spAuthenticationHeader.strPassword;
}
else
{
return "Access Denied";
}
}
}
On this sample it has only one method and based on the username and password mataches it provides access. As like this there are plenty of web methoad's in my webservice and i don't want to check the username and password on all the methoads. instead i wanted to checkonce and provide access to all the methods.
Is it possible to do? please suggest me the best way to achieve this. If there is any online sample please share it with me