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

  • Home
  • SEARCH
  • 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 8490929
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:16:09+00:00 2026-06-10T22:16:09+00:00

I have a webservice that receibes a files with multipart (In c#), when i

  • 0

I have a webservice that receibes a files with multipart (In c#), when i send a big file(15MB) by a chrome extension(Advanced Rest extension) the file uploads ok and i can see the body response:

 <response xmlns="http://schemas.datacontract.org" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Descripcion>blabla</Descripcion>
<Resultado>-9999</Resultado>
<Servicio xmlns:a="http://schemas.datacontract.org" i:nil="true" />
 </reponse>

But when i call with android i get the headers with an 200 code OK response but i dont know how can i get the body response:

This is my code:

/****** Informacion exif *****/

                DefaultHttpClient mHttpClient;
                HttpParams params = new BasicHttpParams();
                params.setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1);
                mHttpClient = new DefaultHttpClient(params);
                HttpPost httppost = new HttpPost("HTTPS://SERVICIO.SVC");
                httppost.setHeader("Connection", "Keep-Alive");
                httppost.setHeader("SOAPAction", "http://tempuri.org/Service1");
                httppost.setHeader("identificadorGUID", Guid);
                httppost.setHeader("numeroServicio", codigoServicio);
                httppost.setHeader("coordenadaLatitud", latitud);
                httppost.setHeader("coordenadaLongitud", longitud);
                if (QUEES == 0) {
                    extension = "jpg";

                }
                if (QUEES == 1) {
                    extension = "mp4";

                }
                httppost.setHeader("cuando", cuando);
                httppost.setHeader("tipoMultimedia", String.valueOf(tipoMultimedia));
                httppost.setHeader("extension", extension);

                MultipartEntity multipartEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
                FileBody fileBody = new FileBody(fichero, "multipart/form-data");
                multipartEntity.addPart("image", fileBody);
                httppost.setEntity(multipartEntity);
                try {
                    HttpResponse response = mHttpClient.execute(httppost);
                    HttpEntity resEntity = response.getEntity();
                    if (resEntity != null) {
                        resEntity.consumeContent();
                    }
                    BufferedReader reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent(), "UTF-8"));
                    String sResponse;
                    StringBuilder s = new StringBuilder();
                    httppost.getAllHeaders();

                    while ((sResponse = reader.readLine()) != null) {
                        s = s.append(sResponse);
                    }
                    Log.i("Respuesta web service", sResponse);
                }
                catch (ClientProtocolException e1) {
                    e1.printStackTrace();
                }
                catch (IOException e1) {
                    e1.printStackTrace();
                }

Crash with: java.io.IOException: Attempted read from closed stream.

How can i get the response to parse it?
Thanks

  • 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-06-10T22:16:11+00:00Added an answer on June 10, 2026 at 10:16 pm

    Looks like you shouldn’t be calling consumeContent() until the information is read (given that it closes the stream). If you’re using 4.1 or later, this method has been deprecated, and you should be using EntityUtils.consume(HttpEntity)

    From its javadoc:

    This method is called to indicate that the content of this entity is no longer required. All entity implementations are expected to release all allocated resources as a result of this method invocation. Content streaming entities are also expected to dispose of the remaining content, if any. Wrapping entities should delegate this call to the wrapped entity.

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

Sidebar

Related Questions

I have a restfull webservice that requires loading trained model files and to create
I have a REST webservice that I need to consume in C#. I need
I have a webservice that I want to query for updates immediately after a
I have a WebService that when I use the instance of this webservice, occurs
I have a WebService that returns XML in a SOAP response: <?xml version=1.0 encoding=utf-8
I have a webservice that returns a list of Clinics near a certain lat/long.
I have a webservice that produce XML result. I have been working on this
I have a webservice method that reads a photo and returns its byte data.
I have an application in which I have a webservice call that returns data
I have read a lot about jquery and i have a simple webservice that

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.