Click here to Skip to main content
11,629,393 members (70,547 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: .NET WCF Android
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 19-Dec-12 9:47am
Edited 19-Dec-12 9:54am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

A RESTful service just takes HTTP requests and sends responses. There must be classes in java that let you do that ?
  Permalink  
Comments
aditya_ingle at 19-Dec-12 15:53pm
   
thnx. i will try. i just start developing 4 android.
Christian Graus at 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)

  Print Answers RSS


Advertise | Privacy | Mobile
Web04 | 2.8.150723.1 | Last Updated 19 Dec 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100