NET 平臺下的WebService
阿新 • • 發佈:2019-02-04
public partial class SOAP : System.Web.UI.Page
{
protected string loginInfo = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
BackgroundWorker bw = new BackgroundWorker();//開啟單獨執行緒執行操作
bw.DoWork += new DoWorkEventHandler(bw_DoWork);//指定要作什麼
//當後臺操作完之後
bw.RunWorkerCompleted += new
//開始後臺操作
bw.RunWorkerAsync();
}
void bw_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
loginInfo = e.Result.ToString();//得到值,如果是可以是DataSet,List<userinfo>等型別
}
void bw_DoWork(object sender, DoWorkEventArgs e)
{
using (ServiceReference1.WebService1SoapClient
{
ServiceReference1.UserInfo info = new ServiceReference1.UserInfo();
info.Name = "admin";
info.Pwd = "admin";
e.Result = client.GetInfo(info);
}
}
}