title: UploadFile: This operation is not supported in the WCF Test Client Because it uses type ClientFileInfo
body: <p>I am fairly new to WCF services and would appreciate some help with this. I am trying to run the WCF as a service and have a ASP.net client on a different machine be able to upload files to it by connecting to the WCF service.</p>
  
  <p>I am testing it with a simple uploading setup (from <a href="http://www.seesharpdot.net/?p=214" rel="nofollow">here</a>) and it works fine if I just reference the WCF Service as a "dll" but if I try to run in it as a WCF Service it gives me an error for the "UploadFile" method by stating that it is not supported.</p>
  
  <p>Exact message with the red X on the method name: This operation is not supported in the WCF Test Client Because it uses type FileUploadMessage.</p>
  
  <p>I start by creating a WCF Service application in Visual Studio 2012 and have the following in my interface (IUploadService.cs):</p>
  
  <pre><code>[ServiceContract]
  public interface IUploadService
  {
      [OperationContract(IsOneWay = true)]
      void UploadFile(FileUploadMessage request);
  }
  
  [MessageContract]
  public class FileUploadMessage
  {
      [MessageBodyMember(Order = 1)]
      public Stream FileByteStream;
  }
  </code></pre>
  
  <p>Its implemented like so (UploadService.svc.cs):</p>
  
  <pre><code>public void UploadFile(FileUploadMessage request)
  {
      Stream fileStream = null;
      Stream outputStream = null;
  
      try
      {
           fileStream = request.FileByteStream;
  
           string rootPath = ConfigurationManager.AppSettings["RootPath"].ToString();
  
           DirectoryInfo dirInfo = new DirectoryInfo(rootPath);
           if (!dirInfo.Exists)
           {
               dirInfo.Create();
           }
  
           // Create the file in the filesystem - change the extension if you wish, 
           // or use a passed in value from metadata ideally
  
           string newFileName = Path.Combine(rootPath, Guid.NewGuid() + ".jpg");
  
           outputStream = new FileInfo(newFileName).OpenWrite();
           const int bufferSize = 1024;
           byte[] buffer = new byte[bufferSize];
  
           int bytesRead = fileStream.Read(buffer, 0, bufferSize);
  
           while (bytesRead &gt; 0)
           {
               outputStream.Write(buffer, 0, bufferSize);
               bytesRead = fileStream.Read(buffer, 0, bufferSize);
           }
       }
       catch (IOException ex)
       {
            throw new FaultException&lt;IOException&gt;(ex, new FaultReason(ex.Message));
       }
       finally
       {
           if (fileStream != null)
           {
               fileStream.Close();
           }
           if (outputStream != null)
           {
               outputStream.Close();
           }
       }
  } // end UploadFile
  </code></pre>
  
  <p>From the looks of it should work but from what I understood by looking at several stackoverflow and other forum questions it seems that WCF doesn't support Stream even though we can have a binding of type streaming. I am confused about this and what I am doing wrong.</p>
  
  <p>Thank you for your help.</p>