TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Dealy
NA
213
0
Request/Respond web service
Jun 29 2016 4:06 AM
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.
Reply
Answers (
2
)
Need a web service for NIH toolbox
Web Service in asp.net mvc 4