需要Web服务帮助

时间:2012-02-16 21:55:17

标签: c# asp.net visual-studio-2010 web-services

我在VS2010中使用C#,我需要一些Web应用程序的帮助。我对Web服务没有多少经验。我获得了一个web服务的URL,其中包含构建应用程序登录部分所需的方法。没有文件。我有登录件工作。然后我卡住了。成功登录后,我需要调用另一个方法,该方法返回经过身份验证的用户可以访问的应用程序的列表(或对象?)。例如,它为我自己返回的项目是(应用程序的名称,描述,位置)。我只是想知道157中是否存在1个应用程序。

我在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行的“角色”上,我可以看到我想要搜索的字段。我想知道“Name”是否包含“Administrator”,但我的所有示例仅在第13行返回“loginService.Role”。它只写了loginService.Roles 20次。我需要进入下一个级别。现在是星期五,这是我的生日,请帮帮我。

[+] roles = Count = 20
[+] {loginService.Role}
    Name = "Administrator"
    nameField = "Administrator"

1 个答案:

答案 0 :(得分:1)

首先,您是通过首先设置服务引用来创建正确的客户端代理类吗?

使用Visual Studio添加服务引用,方法是右键单击项目的“解决方案资源管理器”中的“引用”节点,然后选择“添加服务引用”。您可以按如下方式输入网址:

http://domain.com/Servicename.asmx?WSDL

Visual Studio使用服务返回的WSDL文档来创建代理类。 然后,您可以检查此类以查看所有方法,它们的签名和类型。

几乎所有Web服务都配置为返回此WSDL XML文档。

相关问题