我在VS2010中使用C#,我需要一些Web应用程序的帮助。我没有太多的网络服务经验。我被给了一个web服务的url,其中包含构建应用程序的登录部分所需的方法。没有文件。我有登录一块工作。然后我卡住了。成功登录后,我需要调用另一个方法,它返回经过身份验证的用户有权访问的应用程序的列表(或对象?)。例如,它为我自己返回的项目是(名称,说明,位置)157应用程序。我只想看看是否有1个应用程序存在于157之外。需要Web服务帮助
我在3天内没有运气。我已经能够将结果转储到ArrayList中,并将该列表作为GridView的源代码,但是我不知道如何迭代结果。我现阶段没有包含任何代码,因为我认为我的方法是不正确的,想知道你们会怎么做呢?将生成的对象转换为xml也许?感谢您的反馈和建议。
更新:
protected void Button_Click(object sender, EventArgs e)
{
ServiceReference1.Identity usr = new ServiceReference1.Identity();
loginService.AuthenticationService auth = new loginService.AuthenticationService();
loginService.AuthenticationService auth = new loginService.AuthenticationService();
auth.Login(TextBox1.Text, TextBox2.Text, "10.55.31.91");
List<object> roles = new List<object>(auth.GetIdentityRoles(TextBox1.Text));
IEnumerable myEnum = roles;
IEnumerator myEnumerator = myEnum.GetEnumerator(); //Getting the Enumerator
myEnumerator.Reset(); //Position at the Beginning
while (myEnumerator.MoveNext()) //Till not finished do print
{
Response.Write(myEnumerator.Current.ToString());
}
}
现在,如果我在6号线将鼠标悬停在“角色”,而调试,我可以看到我想要搜索的字段。我想知道“名称”是否包含“管理员”,但我的所有示例仅在第13行返回“loginService.Role”。它仅写入了loginService.Roles 20次。我需要进入下一个阶段。这是星期五,这是我的生日,请帮我出去哈哈。
[+] roles = Count = 20
[+] {loginService.Role}
Name = "Administrator"
nameField = "Administrator"
试图通过ArrayList迭代foreach关键字来检查它的内容? – tomfanning 2012-02-16 21:57:09
即使你的方法不正确,这里的人可能会调整你的工作方法,或者至少指出你的方法不起作用。 – Dan 2012-02-16 21:57:59
另外,不要使用'ArrayList'的习惯。如果您需要任意类型的列表,请使用'列表