我有一个自定义验证器,用于验证Webservice中传入的用户名和密码。 验证完成后,我需要在webservice中使用该用户名和密码。 这是我的CustomValidator
public class ServiceAuthenticator : usernamePasswordValidator
{
private static readonly ILog _log = LogManager.GetLogger("ServiceAuthenticator");
public override void Validate(String username,string password)
{
_log.InfoFormat("-------------{0}/{1}------------------------------",username,password);
if (username == null || password == null)
{
_log.WarnFormat(" Missing User-name / Password {0}/{1}",password);
throw new FaultException("Incorrect User name or Password");
}
}
}
现在我有一个Web服务,我正在尝试获取上述用户名和密码
[WebInvoke(Method = "POST",UriTemplate = "UploadDoc")]
[WebMethod(Description = "Save documents ")]
public void UploadDocGen(RemoteFileInfo remoteFileInfo)
{
// string username = ""; --- How i get the username
// sting Password = ""; -- How to get the password into this
}