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"
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.