异常详细信息: System.Exception: 标头属性/字段 FileServer.header 必须为 SoapHeader 类型或派生类型,或者为 SoapHeader 或 SoapUnknownHeader 的数组。代码: public Authentication header;//定义用户身份验证类变量header
[WebMethod(Description = "need authentiction!")]
[System.Web.Services.Protocols.SoapHeader("header")]
public string GetFile(string filePath)
{
if(header.ValidUser(header.Username,header.Password))
{
FileStream myfile = File.OpenRead(rootdir+filePath);
BinaryReader br = new BinaryReader(myfile);
byte[] btBuf; btBuf = br.ReadBytes((int)myfile.Length);
myfile.Close();
return System.Convert.ToBase64String(btBuf);
}
else return null;
}