需要网络服务帮助

发布于 2025-01-06 13:50:47 字数 1543 浏览 0 评论 0原文

我在 VS2010 中使用 C#,并且需要一些有关 Web 应用程序的帮助。我对网络服务没有太多经验。我获得了一个 Web 服务的 URL,其中包含构建应用程序登录部分所需的方法。没有文档。不过我的登录部分可以工作。然后我就卡住了。成功登录后,我需要调用另一个方法,该方法返回经过身份验证的用户有权访问的应用程序列表(或对象?)。例如,它为我自己返回的项目是 157 应用程序的(名称、描述、位置)。我只是想看看 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.*.*.*");
        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"

I'm using C# in VS2010 and I need some help with a web application. I don't have much experience with web services. I was given the url to a webservice containing methods required to build the login part of the application. No documentation. I have the login piece working though. Then I get stuck. Upon successful login I need to call another method which returns a list (or object?) of applications that the authenticated user has access to. The items it returns for myself for example are (name, description, location) for 157 application. I just want to see if 1 application exists out of the 157.

I have had no luck in 3 days. I have been able to dump the results into an ArrayList and make that list the source for a GridView, but I don't know how to just iterate through the results. I am not including any code at this stage because I don't think my approach is correct and want to know how you all would go about it? Convert the resulting object to xml maybe? I appreciate your feedback and advice.

UPDATED:

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.*.*.*");
        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());
        }
    }

Now, if I hover over "roles" in line 6 while debugging I can see the field I want to search. I want to know if "Name" contains "Administrator" but all my examples only return "loginService.Role" in line 13. It just writes loginService.Roles 20 times. I need to get down to the next level. It's Friday and it's my Birthday, please help me out lol.

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

∝单色的世界 2025-01-13 13:50:47

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

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

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

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

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

First of all, are you creating a proper client proxy class by setting a Service reference first?

Use Visual Studio Add Service Reference by right-clicking the References node in the Solution Explorer for the project, and choosing "Add Service Reference". You would enter the url as follows:

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

The WSDL document that the service returns is used by Visual Studio to create the proxy class.
You can then inspect this class to see all the methods, their signatures and types.

Almost all Web services are configured to return this WSDL XML document.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文