Sending a list to a web service
I have an object that contains a list of Email addresses and EmailIDs.
Code:
public class DataObjects
{
public class UserEmails
{
private string _Email;
public string Email
{
get { return _Email; }
set { _Email = value; }
}
private int _EmailID;
public int EmailID
{
get { return _EmailID; }
set { _EmailID = value; }
}
}
}
And I populate it like this:
Code:
protected void GetEmails()
{
DataAccess da = new DataAccess(); //this is a separate Data Access class with loads of methods to access the database
List<DataObjects.UserEmails> myUserEmailsList = new List<DataObjects.UserEmails>(); //create a list of UserEmails objects
myUserEmailsList = da.getUserEmails(1); //this passes in a UserID to the data access function that returns me a list of emails for this user
myPassedList(myUserEmailsList); //I pass the list to another function just to prove the data is there and can be retrieved.
}
The last line in GetEmails passes the list to myPassedList
Code:
protected void myPassedList(IList EmailsList)
{
foreach (DataObjects.UserEmails myUserEmails in EmailsList) //loop through the list to prove it is populated etc.
{
int EmailID = myUserEmails.EmailID;
string Email = myUserEmails.Email;
}
}
Everything above works fine. Here's the question. When I am at the point where I have populated the List of UserEmails - I need to pass it to a web service for someone else to access the data.
I pass my list to a function and I can loop through it by writing:
foreach (DataObjects.UserEmails myUserEmails in EmailsList)
which is fine, for me, because my application knows what DataObjects.UserEmails means ... the people receiving the list won't. They are just getting a list.
Can they loop through the list I pass them without knowing the structure of the object in the list and just extract the data?
Thanks for any help.
Re: Sending a list to a web service
The person who created that webservice has probably created the specs, if you follow those specs, the other side can handle your data