Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6712535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:16:15+00:00 2026-05-26T08:16:15+00:00

I am using an Android client to upload files to a wcf service. The

  • 0

I am using an Android client to upload files to a wcf service.
The upload is working, but now I want to get the name of the file and another integer parameter into the request.

How can I do this? afaik, I can not use a message contract since I am not packaging the message as SOAP. Is there an alternative?

I use this code on the Android side:

ByteArrayOutputStream bos = new ByteArrayOutputStream();
        bm.compress(CompressFormat.JPEG, 75, bos);
        byte[] data = bos.toByteArray();
        HttpClient httpClient = new DefaultHttpClient();
        HttpPost postRequest = new HttpPost(serviceAddress +
                "/Upload/");
        ByteArrayBody bab = new ByteArrayBody(data, "forest.jpg");

        MultipartEntity reqEntity = new MultipartEntity(
                HttpMultipartMode.BROWSER_COMPATIBLE);
        reqEntity.addPart("step", new StringBody("1"));
        reqEntity.addPart("fileName", new StringBody("elad.jpg"));
        reqEntity.addPart("file", bab);
        postRequest.setEntity(reqEntity);
        HttpResponse response = httpClient.execute(postRequest);
        BufferedReader reader = new BufferedReader(new InputStreamReader(
                response.getEntity().getContent(), "UTF-8"));
        String sResponse;
        StringBuilder s = new StringBuilder();

        while ((sResponse = reader.readLine()) != null) {
            s = s.append(sResponse);

and this code on the wcf side (just for teesting):

 [WebInvoke(UriTemplate = "", Method = "POST", BodyStyle= WebMessageBodyStyle.Bare)]
    public void Upload(Stream fileStream)
    {
        FileStream targetStream = null;
        string uploadFolder = @"C:\inetpub\wwwroot\Upload\test.jpg";
        using (targetStream = new FileStream(uploadFolder, FileMode.Create,
            FileAccess.Write, FileShare.None))
        {
            const int bufferLen = 65000;
            byte[] buffer = new byte[bufferLen];
            int count = 0;
            while ((count = fileStream.Read(buffer, 0, bufferLen)) > 0)
            {
                targetStream.Write(buffer, 0, count);
            }
            targetStream.Close();
            fileStream.Close();
        }
    }

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:16:16+00:00Added an answer on May 26, 2026 at 8:16 am

    You can pass an additional parameter other than the Stream one in the URI. The post at http://blogs.msdn.com/b/carlosfigueira/archive/2008/04/17/wcf-raw-programming-model-receiving-arbitrary-data.aspx has an example of a service with that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to develop facebook client in android using fbrocket api.but,this api only allows
i made news applicaion in android using RSS feed and now i want to
I want to print file using wifi printing in my android application.I have scanned
I have WCF RESTful service and Android client. Server replies with 400 when I
I have a self-hosted WCF web service running, and an Android client application. I
I want to send a csv file from Android to Python AppEngine. I'm using
I am trying to play continuous stream using android mediaplayer.but am not able to
I want to send a double value from my android client to the PHP
I am writing a RTSP client in Android for streaming video using Android SDK.
Trying to call from an android client, using the signpost oauth libs. I generated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.