我正在使用 Silverlight 开发一个 Windows 小工具,我需要调用一个 asp.net Web 服务,它返回一个带有一些数据的对象。我想接收该对象并显示数据。
我的代码如下
Web 服务代码。
[WebMethod]
public userdata LogIn(string username,string user_password)
{
return udata;
}
return new userdata();
}
}
我的自定义类代码是
public class userdata
{
string name;
public string Name
{
get { return name; }
set { name = value; }
}
string userName;
public string UserName
{
get { return userName; }
set { userName = value; }
}
string department;
public string Department
{
get { return department; }
set { department = value; }
}
string designation;
public string Designation
{
get { return designation; }
set { designation = value; }
}
string email;
public string Email
{
get { return email; }
set { email = value; }
}
string mobile;
public string Mobile
{
get { return mobile; }
set { mobile = value; }
}
string ip;
public string Ip
{
get { return ip; }
set { ip = value; }
}
string id;
public string Id
{
get { return id; }
set { id = value; }
}
}
它返回
<userdata>
<Name>Asik</Name>
<UserName>asikcse</UserName
><Department>technical</Department>
<Designation>Software Programmer</Designation>
<Id>1</Id>
</userdata>
在我的项目结束时,我添加了 Web 引用作为引用,但对此没有任何解决方案。
LoginServiceSoapClient login = new LoginServiceSoapClient();
login.LogInCompleted+=new EventHandler<LogInCompletedEventArgs>(login_LogInCompleted);
login.LogInAsync(log._nameText, log._surnameText);
}
void login_LogInCompleted(object sender, LogInCompletedEventArgs e)
{
How can I retrieve this object returned by webmethod
}