直接到代码
服务端代码:有两个类,一个是定义用户名密码的类,一个是定义webservice方法的类
定义用户名密码的类:
using System;
using System.Collections.Generic;
using System.Web;
namespace WebService1
{
public class YanZheng:System.Web.Services.Protocols.SoapHeader//注意这个继承
{
private string _uname;
private string _pass;
public string uname
{
get;
set;
}
public string pass
{
get;
set;
}
public bool yanzhenguser(string username, string password)
{
if ((username == "cao") && (password == "cao"))
{
return true;
}
else
{
return false;
}
}
}
}
定义webservice方法的类:
p