1 首先建立Web Sevices
简单的一个Web Services 输入用户ID,返回用户信息
[WebMethod]
public User GetUserInfo(string UserID)
{
LoginBusiness lb = new LoginBusiness();
return lb.GetUserInfo(UserID);
}
public User GetUserInfo(string UserID)
{
LoginBusiness lb = new LoginBusiness();
return lb.GetUserInfo(UserID);
}
2 建立WPF Application 程序
3 在程序中添加Add Service References 服务引用
地址类似:http://localhost:1742/SoldierServices.asmx,名称为SoldierServices
4 Xaml文件上添加一个button,并且添加事件
Click="btnSignin_Click"
5 编写btnSignin_Click事件
private void btnSignin_Click(object sender, RoutedEventArgs e)
{
SoldierServices.User userinfo = new SoldierServices.User();
SoldierServices.SoldierServicesSoapClient SoldierClient = new SoldierServices.SoldierServicesSoapClient();
userinfo = SoldierClient.GetUserInfo("1");
MessageBox.Show(userinfo.UserName);
}
{
SoldierServices.User userinfo = new SoldierServices.User();
SoldierServices.SoldierServicesSoapClient SoldierClient = new SoldierServices.SoldierServicesSoapClient();
userinfo = SoldierClient.GetUserInfo("1");
MessageBox.Show(userinfo.UserName);
}
6 结束