title: JavaScript and/or JavaScript code using jquery invoking WCF Service retrieving a collection of System.IO.Stream?
body: <p>I am creating a WCF service that will be consumed by plain JavaScript on the client side and some jQuery JavaScript on the client side as well.</p>
  
  <p>1) How can I implement the plain client JavaScript so that it will invoke the WCF Service in such a way that it will retrieve a collection of System.IO.Stream at once? Moreover, how would I iterate through the collection that was received on the plain JavaScript side in such a way that I can associate each of the System.IO.Stream objects in the collection to an HTML image element?</p>
  
  <p>2) Is it possible to implement the JavaScript code that uses jquery so that it will invoke the WCF Service in such a way that it will retrieve a collection of System.IO.Stream at once? Moreover, how would I iterate through the collection that was received by the JavaScript that uses jQuery in such a way that I can associate each of the System.IO.Stream objects in the collection to an HTML image element?</p>
  
  <pre><code> /*********Start of Excerpt from the Interface Code of a WCF Service 
  
    Contract*****************/ 
  
    using System; 
  
    using System.Collections.Generic; 
  
    using System.Linq; 
  
    using System.Runtime.Serialization; 
  
    using System.ServiceModel; 
  
    using System.ServiceModel.Activation; 
  
    using System.Text; 
  
    using System.ServiceModel.Web; 
  
    using System.IO; 
  
    using ConsoleForWCFServiceTutorial.PerlsDataContracts; 
  
    using ConsoleForWCFServiceTutorial.DataAccessObjectsDAO; 
  
  
    namespace ConsoleForWCFServiceTutorial 
  
    { 
  
       [ServiceContract(Namespace = 
  
    "http://ConsoleForWCFServiceTutorial.CarService")] 
  
       public interface ICarService 
  
       { 
  
      [OperationContract] 
  
      [WebInvoke(Method = "GET", 
  
                      BodyStyle = WebMessageBodyStyle.WrappedRequest)] 
  
           Stream[] getImagesList(); 
  
  
  
  
       } 
  
    } 
  
    /*********End of Excerpt from the Interface Code of a WCF Service 
    Contract*****************/ 
  
  
  
  
    /*********Start of Excerpt of the code associated with the Class that 
    implements the WCF Service Contract*****************/ 
  
    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Text; 
    using System.Collections; 
    using System.ServiceModel.Activation; 
    using System.Configuration; 
    using System.Data; 
    using System.IO; 
    using System.ComponentModel; 
    using ConsoleForWCFServiceTutorial.PerlsDataContracts; 
    using ConsoleForWCFServiceTutorial.DataAccessObjectsDAO; 
  
  
    namespace ConsoleForWCFServiceTutorial 
    { 
         [AspNetCompatibilityRequirements(RequirementsMode = 
         AspNetCompatibilityRequirementsMode.NotAllowed)] 
    class CarService : ICarService 
    { 
  
          public Stream[] getImagesList() 
           { 
  
  
               List&lt;Stream&gt; myImagesList = new List&lt;Stream&gt;(); 
  
               string fileName = Path.Combine("BMWpicture.jpg"); 
  
               FileStream fileStream = 
                 new FileStream(fileName, FileMode.Open, FileAccess.Read); 
               // Set the content type as image/ jpeg 
               System.ServiceModel.Web.WebOperationContext. 
                 Current.OutgoingResponse.ContentType = "image/jpeg"; 
  
  
               myImagesList.Add(fileStream); 
  
               string fileName2 = Path.Combine     ("MercedesBenzpicture.jpg"); 
  
               FileStream fileStream2 = 
            new FileStream(fileName2, FileMode.Open, FileAccess.Read); 
               // Set the content type as image/ jpeg 
               System.ServiceModel.Web.WebOperationContext. 
                 Current.OutgoingResponse.ContentType = "image/jpeg"; 
  
  
               myImagesList.Add(fileStream2); 
  
               return myImagesList.ToArray(); 
           } 
       } 
    } 
    /*********End of Excerpt of the code associated with the Class that 
    implements the WCF Service Contract*****************/ 
  
  
    &lt;!--Start of Excerpt of the plain JavaScript client code that 
    invokes one of the Methods in the WCF Service 
    Contract--&gt; 
  
    &lt;script type="text/javascript"&gt; 
  
    function getImagesList2() { 
  
      var listOfStreams = 
    'http://localhost:8732/Design_Time_Addresses/ConsoleForWCFServiceTutorial/c     arService     /getImagesList' 
  
      document.getElementById("image11").onload = function () { 
        }; // img.onload = function() 
  
  
    document.getElementById("image11").src = listOfStreams[0]; 
  
  
  
      document.getElementById("image12").onload = function () { 
           }; // img.onload = function() 
  
  
         document.getElementById("image12").src = listOfStreams[1]; 
  
    } 
    &lt;/script&gt; 
    &lt;!--End of Excerpt of the plain JavaScript client code that 
    invokes one of the Methods in the WCF Service 
    Contract--&gt; 
  
    &lt;!--Start of Excerpt of the HTML code that is affected by the 
    JavaScript client and WCF Service interaction--&gt; 
    &lt;body&gt; 
       &lt;form id="form1" runat="server"&gt; 
       &lt;div&gt; 
  
  
                    &lt;img src=""  id="image11" alt="Smiley face" /&gt;      
  
                  &lt;img src=""  id="image12" alt="Smiley face" /&gt; 
  
  
            &lt;br /&gt; 
            &lt;a class="large blue button" id="A7" 
    onClick="getImagesList2()"&gt;getImagesList2&lt;/a&gt; 
  
  
           &lt;/div&gt; 
       &lt;/form&gt; 
    &lt;/body&gt; 
    &lt;/html&gt; 
  
    &lt;!--End of Excerpt of the HTML code that is affected by the 
   JavaScript client and WCF Service interaction--&gt; 
  </code></pre>
  
  <p>1) How can I implement the plain client JavaScript so that it will invoke the WCF Service in such a way that it will retrieve a collection of System.IO.Stream at once? Moreover, how would I iterate through the collection that was received on the plain JavaScript side in such a way that I can associate each of the System.IO.Stream objects in the collection to an HTML image element?</p>
  
  <p>2) Is it possible to implement the JavaScript code that uses jquery so that it will invoke the WCF Service in such a way that it will retrieve a collection of System.IO.Stream at once? Moreover, how would I iterate through the collection that was received by the JavaScript that uses jQuery in such a way that I can associate each of the System.IO.Stream objects in the collection to an HTML image element?</p>