Reputation: 11972
Using C#
Currently I am using web service to display the employee details
Current Logic
Getting the 4 inputs (employee id, name, date of join, email) as a string, sending the input to DB as a parameter and retrieve the procedure output in dataset and displayed the dataset output (employee id, name, date of join, email, address, passport no, etc). This is working fine for single employee information.
Now I want to get the bulk employee input and display the bulk employees output in web service
How to get the bulk employees input details
For example, If the application want to get 20 employee details, then application need to provide employee id, name, date of join, email as a input for 20 employees.
How the application send a request to webservice for 20 * 4 = 80 input through dataset or any other idea?
Can any one help or suggest me
If the question is not clear or any doubt, please feel free to ask me.
Upvotes: 1
Views: 639
Reputation: 356
You should create a class with the request properties like:
public class RequestParams
{
public int employeeID { get; set; }
public string Name { get; set; }
public DateTime DateOfJoin { get; set; }
public string Email { get; set; }
}
this will be your Method input params:
public EmployeesDetails GetDetails(RequestParams[] r)
Make sure to use the same structure in your javascript and use JSON.Parse to have it parsed correctly
*Edit, example:
[WebMethod]
public EmployeesDetails GetDetails(RequestParams[] request)
{
// Query the database, request contains an array of RequestParams
}
public class RequestParams
{
public int employeeID { get; set; }
public string Name { get; set; }
public DateTime DateOfJoin { get; set; }
public string Email { get; set; }
}
public class EmployeesDetails
{
public int PassportNumber { get; set; }
}
JSON example (dont catch me on parsing error, i wrote it quickly manual):
{'request':[
'RequestParams':{
'employeeID':'1',
'Name':'1',
'DateOfJoin':'1',
'Email':'[email protected]'},
{
'employeeID':'2',
'Name':'2',
'DateOfJoin':'2',
'Email':'[email protected]'},
{
'employeeID':'3',
'Name':'3',
'DateOfJoin':'3',
'Email':'[email protected]'},
{
'employeeID':'4',
'Name':'4',
'DateOfJoin':'4',
'Email':'[email protected]'}
}]}
Upvotes: 1
Reputation: 761
Usually for something like that you need to do a POST with some kind of attached blob of data (the data itself can be any format you like, as long as your server will understand it and respond accordingly). You could conceivably pass them all in the URL but that'd be kinda crazy.
Upvotes: 1