Click here to Skip to main content
15,884,298 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;
                bytesRead = fileStream.Read(bytearray, 0, bytearray.Length);
                totalBytesRead += bytesRead;
            } while (bytesRead > 0);

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


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

Updated 19-Dec-12 9:54am

1 solution

A RESTful service just takes HTTP requests and sends responses. There must be classes in java that let you do that ?
Share this answer
mryeti 19-Dec-12 15:53pm    
thnx. i will try. i just start developing 4 android.
Christian Graus 19-Dec-12 15:54pm    
Try this :

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