public class UserCredentialsSoapHeader : SoapHeader
{
public string UserName;
public string Password;
}
[SopHeader("UserCredentials")]
public MyWebService : WebService
{
//1) Must be public
//2) Name must be the same as the name given in the above attribute
public UserCredentialsSoapHeader UserCredentials;
[WebMethod]
public string HelloWorld()
{
if (UserCredentials == null)
throw new ........("UserCredentials required");
return "Hello " + UserCredentials.UserName;
}
}
I have just changed my webservices from using this approach to a ticket
approach instead. I return a Guid from a LogIn(username, password) method.
The Guid is a key to the username/password in the Cache object. It is must
clearer in my opinion as to which methods require a login now, because they
all start with "Guid SessionID"
Pete