title: Upload Image using WCF service from Android: Cannot process because of content type
body: <p>I am getting the error below while trying to upload the image.</p>
  
  <blockquote>
    <p>Cannot process the message because the content type 'multipart/form-data; boundary=AwQm1pbogJ6qQuZlUZjJ6kNOvbehrlyozA-w' was not the expected type 'text/xml; charset=utf-8'.</p>
  </blockquote>
  
  <p><strong>Android Code :</strong> </p>
  
  <pre><code>HttpPost httppost = new HttpPost("http://192.168.1.111/androidservice/MediaUploadService.svc/uploadFile");
  File photo = new File(Environment.getExternalStorageDirectory(), "01.jpg");
  MultipartEntity t = new MultipartEntity();
  t.addPart("t", new FileBody(photo));
  httppost.setEntity(t);
  HttpClient httpclient = new DefaultHttpClient();
  HttpResponse response = httpclient.execute(httppost);
  </code></pre>
  
  <p><strong>WCF Code :</strong></p>
  
  <pre><code>namespace AndroidService
  {
  // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "MediaUploadService" in code, svc and config file together.
  public class MediaUploadService : IMediaUploadService
  {
      public void UploadFile(Stream fileContents)
      {
         byte[] buffer = new byte[10000];
          int bytesRead, totalBytesRead = 0;
          do
          {
              bytesRead = fileContents.Read(buffer, 0, buffer.Length);
              totalBytesRead += bytesRead;
          } while (bytesRead &gt; 0);
          File.WriteAllText(@"D:\\Vechile\log2.txt", totalBytesRead.ToString());
      }
  }
  }
  </code></pre>
  
  <p><b>Binding:</b></p>
  
  <pre><code>  &lt;system.serviceModel&gt;
  &lt;behaviors&gt;
    &lt;endpointBehaviors&gt;
      &lt;behavior name="httpBehavior"&gt;
        &lt;webHttp /&gt;
      &lt;/behavior&gt;
    &lt;/endpointBehaviors&gt;
  
    &lt;serviceBehaviors&gt;
      &lt;behavior name=""&gt;
        &lt;serviceMetadata httpGetEnabled="true" /&gt;
        &lt;serviceDebug includeExceptionDetailInFaults="false" /&gt;
      &lt;/behavior&gt;
  
      &lt;behavior name="PublishMetadataBehavior"&gt;
        &lt;serviceMetadata httpGetEnabled="true" policyVersion="Policy15"/&gt;
      &lt;/behavior&gt;
  
    &lt;/serviceBehaviors&gt;
  &lt;/behaviors&gt;
  
  &lt;bindings&gt;
    &lt;webHttpBinding&gt;
      &lt;binding name="WebHttpDtreaming" transferMode="Streamed" &gt;
      &lt;/binding&gt;
    &lt;/webHttpBinding&gt;
  &lt;/bindings&gt;
  
  &lt;standardEndpoints&gt;
    &lt;webHttpEndpoint&gt;
     &lt;standardEndpoint name=""
                    helpEnabled="true"
                    automaticFormatSelectionEnabled="true"
                    maxReceivedMessageSize="1000000"/&gt;
    &lt;/webHttpEndpoint&gt;
  &lt;/standardEndpoints&gt;
  
  &lt;serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>I would appreciate any help.</p>