title: WCf service file download
body: <p>I am creating WCF service that will download &amp; upload xml files.  When trying to download a file to a client, it gives me the following error:</p>
  
  <p>"The content type text/html; charset=utf-8 of the response message does not match the content type of the binding (multipart/related; type=\"application/xop+xml\"). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 1024 bytes of the response were: ' \nhttp://www.w3.org/1999/xhtml\"> \n \nIIS 7.0 Detailed Error - 500.19 - Internal Server Error \n \n</p>
  
  <p>I am using basicHTTPBinding as my binding protocol.  My webservice is currently hosted on my own pc on IIS7.0 under Vista Home Premium.  The download code in the service I am using is the following:</p>
  
  <pre><code> public Stream Download( string path )
      {
          try
          {
              using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read))
              {
  
                  return stream;
              }
          }
          catch (Exception ex)
          {
              string error = ex.Message;
  
              return null;
          }
      }
  </code></pre>
  
  <p>The code on my client that is supposed to download the file is the following, using just an ordinary test file:</p>
  
  <pre><code> System.IO.FileStream fs;
          try
          {
              fs = (System.IO.FileStream)client.Download(@"C:\UploadedFiles\Test.txt");
              byte[] arr = new byte[fs.Length];
              int read;
              do
              {
                  read = fs.Read(arr, 0, arr.Length);
  
              } while (read != arr.Length);
  
              Console.WriteLine(ASCIIEncoding.ASCII.GetString(arr));
              Console.ReadLine();
          }
          catch (Exception Ex)
          {
              string error = Ex.Message;
              string inner = Ex.InnerException.ToString(); ;
              Console.WriteLine("Exception: {0}/nInner Exception: {1}",error,inner);
              Console.ReadLine();
          }
  </code></pre>
  
  <p>Someone please help me out, I don't understand what is wrong?</p>
  
  <p>If you need more data to help me resolve, also let me know.</p>
  
  <p>Thanks a lot,
  T</p>