Results 1 to 2 of 2

Thread: Sending a list to a web service

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    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.

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    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
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width