Hello,
I'm new to web services so I could use a little help.
I have a project that a web service will request data from me and I will respond with a web service giving the data. I've created the response web service as you can see below:
Person.cs
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Web;
-
- namespace TestWebServices
- {
- public class Person
- {
- public string IdNo { get; set; }
- public string FirstName { get; set; }
- public string LastName { get; set; }
- }
- }
[WebMethod]
- [WebMethod(Description = "Return Applicants")]
- publicPerson[] retApplicants(String idno)
- {
string connString = ConfigurationManager.ConnectionStrings["conn"].ConnectionString;
SqlConnection connection = new SqlConnection(connString);
-
- SqlCommand command = new SqlCommand("selectApplicant", connection);
- command.CommandType = System.Data.CommandType.StoredProcedure;
- command.Parameters.Add("@idno", SqlDbType.VarChar).Value = idno;
- connection.Open();
- SqlDataReader reader = command.ExecuteReader();
-
- List<Person> persons = new List<Person>();
- Person persReturned;
-
- while (reader.Read())
- {
- persReturned = new Person();
- persReturned.IDNO = reader["IdNo"].ToString();
- persReturned.FirstName = reader["FirstName"].ToString();
- persReturned.LastName= reader["LastName"].ToString();
- persons.Add(persReturned);
- }
-
- return persons.ToArray();
- }
I tested it on my browser by invoking and it works fine.
How can I make it respond to the requested idno from the other web service?
Thank you in advance.