title: creating a webservice that accepts a file (Stream) doesnt want other params
body: <p>I have a File i want to upload to a Webservice, but it needs additional params, so I create some hidden fields with the associated name:value pairs to get pushed to the server request.  The issue though is the definition of the service.</p>
  
  <p>[Error]</p>
  
  <p><strong>Operation 'NewImage' in contract 'IFormServices' has multiple request body parameters, one of which is a Stream. When the Stream is a parameter, there can be no other parameters in the body.</strong></p>
  
  <p>[interface]</p>
  
  <pre><code>[OperationContract]
      [WebInvoke(Method = "POST",
          ResponseFormat = WebMessageFormat.Json)]
      string NewImage(Stream data, string server,string datasource, string document, string image_id);
  </code></pre>
  
  <p>[definition]</p>
  
  <pre><code>public string NewImage(Stream data, string server, string datasource, string document, string image_id)
          {
          //this should, similar to others, need a server, datasource, and some sort of document in which to append the images.
          WebClient wsb = new WebClient();
          string str = "_URL_";
          byte[] byte_data = new byte[data.Length];
          data.Read(byte_data, 0, byte_data.Length);
          byte[] response = wsb.UploadData(str,"POST",byte_data);
          string retVal = Convert.ToString(response);
          //want to return a JSON.serialized dictionary of:  given image_id + id returned from response.
          Dictionary&lt;string, object&gt; retDict = new Dictionary&lt;string, object&gt;();
          retDict["filename"] = image_id;
          retDict["id"] = "";
          //return new JavaScriptSerializer().Serialize(json);
          return "-1";
          }
  </code></pre>
  
  <p>[javascript code]</p>
  
  <pre><code>var $form = $("&lt;form /&gt;").attr({
                  method: "POST",
                  enctype: "multipart/form-data",
                  target: "image_processing",
                  action: "webservices/FormServices.svc/NewImage",
                  id: "push_image_to_server"
              } ).appendTo( "body" );
              var im_id = $( this ).attr( "image_id" );
              $( this ).appendTo( "form#push_image_to_server" );
              $( "&lt;input type='hidden' /&gt;" ).attr( { name: "server", value: BASE_URL } ).appendTo( $form );
              $( "&lt;input type='hidden' /&gt;" ).attr( { name: "datasource", value: SELECTED_DATASOURCE } ).appendTo( $form );
              $( "&lt;input type='hidden' /&gt;" ).attr( { name: "document", value: SELECTED_DOCUMENT } ).appendTo( $form );
              $( "&lt;input type='hidden' /&gt;" ).attr( { name: "image_id", value: im_id } ).appendTo( $form );
              $("iframe#image_processing").bind("load", function (a,b,c) {
                  console.log("SUCCESS", arguments);
                  $( "iframe#image_processing" ).unbind( "load", function (a,b,c)
                  {
                      console.log( arguments );
                      _IMAGE_UPLOADS_[a["filename"]] = a["id"];
                  } );
                  $( "form#push_image_to_server" ).remove();
              } );
  </code></pre>
  
  <p>So i am trying to figure out a way to send up 4 strings + a file to the server.</p>
  
  <p>How would this be done?</p>
  
  <p><strong>edit:</strong> put error code at top.</p>