Click here to Skip to main content
15,123,367 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi, i am trying to consume a wcf rest service on android but its not working. a short snippet of "how to consume restful service on android" or "how to upload a file using android" will help me plz.


public void upload(string fileName, Stream fileStream)
        {

            FileStream fileToupload = new FileStream("e:\\" + fileName, FileMode.Create);

            byte[] bytearray = new byte[10000];
            int bytesRead, totalBytesRead = 0;
            do
            {
                bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
                totalBytesRead += bytesRead;
            } while (bytesRead > 0);

            fileToupload.Write(bytearray, 0, bytearray.Length);
            fileToupload.Close();
            fileToupload.Dispose();

        }



[ServiceContract]
public interface IImageUpload
   {
       [OperationContract]
       [WebInvoke(Method = "POST", UriTemplate = "FileUpload/{fileName}")]
       void upload(string fileName, Stream fileStream);

   }
Posted
Updated 19-Dec-12 10:54am
v2

1 solution

A RESTful service just takes HTTP requests and sends responses. There must be classes in java that let you do that ?
   
Comments
aditya_ingle 19-Dec-12 15:53pm
   
thnx. i will try. i just start developing 4 android.
Christian Graus 19-Dec-12 15:54pm
   
Try this : https://www.google.com.au/search?q=android+consume+restful+service&rls=com.microsoft:en-au:IE-Address&ie=UTF-8&oe=UTF-8&sourceid=ie7&redir_esc=&ei=VynSUJLWFc2TiAf-hYGgDw

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900