List Array in Web Service

Posted on 2009-04-25
Last Modified: 2012-05-06
I have the following code which I can use to get one offs of each item.  But if I would also receive order information and there could be X number of products how would I modify this and how would I then retreive those in my code?
public class Service1 : System.Web.Services.WebService



        public string InsertOrder(

              string CustomerID

            , string FirstName

            , string LastName

            , string Address1

            , string Address2

            , string Address3

            , string City

            , string County

            , string Postcode

            , string Telephone

            , string Mobile

            , string Email

            , string dFirstName

            , string dLastName

            , string dAddress1

            , string dAddress2

            , string dAddress3

            , string dCity

            , string dCounty

            , string dPostCode



        /// MyCode



Open in new window

Question by:andrewmilner
    LVL 14

    Accepted Solution


    Use like this.

    public class Service1 : System.Web.Services.WebService
            public string InsertOrder(List<OrderDetail> orders)
            /// MyCode
    public class OrderDetail
     public string CustomerID;
     public string string FirstName;
     public string LastName;
     public string Address1;
     public string Address2;
     public string Address3;
     public string City;
     public string County;
     public string Postcode;
     public string Telephone;
     public string Mobile;
     public string Email;
     public string dFirstName;
     public string dLastName;
     public string dAddress1;
     public string dAddress2;
     public string dAddress3;
     public string dCity;
     public string dCounty;
     public string dPostCode;

    Open in new window


    Author Comment


    Then how would I access / loop through each item in the code?
    LVL 14

    Expert Comment

            public string InsertOrder(List<OrderDetail> orders)
                   foreach(OrderDetail order in orders)

    Author Comment

    Many Thanks for your help.

    How would I go about inserting to the WebService.  I have the code below so far but I guess I would need to define a List on the sending end and then somehow get this into the WebService call.
                string result = Service1.InsertOrder(

    Open in new window


    Author Comment


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now