title: Get & Post image from Android to WCF
body: <p>i wanna send image along with text from my android client to wcf web service on localhost. i have successfully sent text and received as well and as it was quite difficult for me just to send text but now i have to send image along with text as well. i'd prefer not to change my method like using stream etc. i want to pass image as json and receive it in my web service and store it in sql database image column or even storing on disc would do. So please tell me what changes i need to make in code below to do it. 
  Thanks in advance...!</p>
  
  <p>here's my AddIssue method of web service.</p>
  
  <pre><code>    public int AddIssue(Issue issue)
  {
     // byte[] bm=System.Convert.FromBase64String(issue.Image.ToString());
      //Binary bo = new Binary(bm);
  
      try
      {
          NorthwindDataContext dc = new NorthwindDataContext();
          Issue currentIssue = new Issue
          {
              Area = issue.Area,
              Description= issue.Description,
             // Image =bo
  
          };
  
          if (currentIssue == null)
          {
              // Couldn't find an [Order] record with this ID
              return -3;
          }
          dc.Issues.InsertOnSubmit(currentIssue);
          // Update our SQL Server [Order] record, with our new Shipping Details (send from whatever
          // app is calling this web service)
  
          dc.SubmitChanges();
  
          return 0;     // Success !
      }
      catch (Exception)
      {
          return -1;
      }
  }
  </code></pre>
  
  <p>and here's my java code. i have tried different codes but none worked. the above two codes work with a C# client but i need it in java i.e android.</p>
  
  <p>JSONObject json = new JSONObject();</p>
  
  <pre><code>           json.put("Area",editTextPrice.getText().toString()); 
             json.put("Description",editTextDescription.getText().toString());
             img.buildDrawingCache();
             Bitmap bm=img.getDrawingCache();
             ByteArrayOutputStream baos = new ByteArrayOutputStream();  
             bm.compress(Bitmap.CompressFormat.JPEG, 100, baos); //bm is the bitmap object   
             byte[] b = baos.toByteArray();
             String encodedImage = Base64.encodeToString(b , Base64.DEFAULT);
             json.put("Image",encodedImage);
  </code></pre>
  
  <p>issue class of my web service</p>
  
  <pre><code>namespace JSONWebService
  {
      [DataContract]
      [Serializable]
      public class wsIssue
      {
          [DataMember]
          public int IssueId { get; set; }
  
          [DataMember]
          public string Area { get; set; }
  
          [DataMember]
          public string Description { get; set; }
          [DataMember]
          public string Image { get; set; }
  
      }
  </code></pre>
  
  <p>n here's interface of my web service</p>
  
  <pre><code>namespace JSONWebService
  {
  
      // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IService1" in both code and config file together.
      [ServiceContract]
      public interface IService1
      {
          [OperationContract]
          [WebInvoke(Method = "GET", ResponseFormat = WebMessageFormat.Json, UriTemplate = "getAllIssues")]
          List&lt;wsIssue&gt; GetAllIssues();
          [OperationContract]
          [WebInvoke(Method = "POST", ResponseFormat = WebMessageFormat.Json,RequestFormat = WebMessageFormat.Json, UriTemplate = "AddIssue")]
          int AddIssue(Issue issue);
  </code></pre>
  
  <p>i have tried directly using json.toString() instead of byte but that didn't work either.</p>