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 4105928
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:18:39+00:00 2026-05-20T21:18:39+00:00

I needed to send some XML to a webservices and I was able to

  • 0

I needed to send some XML to a webservices and I was able to do it with a normal StringEntity because it was just text but now I need to attach an image to it as well. I tried doing it with a MultipartEntity but I couldn’t get it working with just the XML.

// Working

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost doc = new HttpPost("http://mywebservices.com");

HttpEntity entity = new StringEntity(writer.toString());
httppost.setEntity(entity);

HttpResponse response = httpclient.execute(httppost);
HttpEntity responseEntity = response.getEntity();

// not working

DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httppost doc = new HttpPost("http://mywebservices.com");

// no difference when removing the BROWSER_COMPATIBLE   
MultipartEntity entity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE); 
entity.addPart("xml", new StringBody(writer.toString()));
httppost.setEntity(entity);

HttpResponse response = httpclient.execute(httppost);
HttpEntity responseEntity = response.getEntity();

And is there a way I could see the MIME that is being send?

  • 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-20T21:18:39+00:00Added an answer on May 20, 2026 at 9:18 pm

    You simply forgot:

    httppost.setEntity(entity);
    

    By the way, it’s probably good form to set the Content-Type of your parts, e.g.:

    entity.addPart("xml", new StringBody(writer.toString(),"application/xml",Charset.forName("UTF-8")));
    

    As far as seeing what’s being sent, see http://hc.apache.org/httpcomponents-client-ga/logging.html (especially “wire logging”) for the HttpClient logging features, and
    this question for how to get it working on Android.

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

Sidebar

Related Questions

Needed Finfo but deleted msi package, so uninstalled php 5.3.0, downloaded 5.3.2 and installed.
I needed some simple string encryption, so I wrote the following code (with a
I needed to re-install my computer but I didn't think about exporting the data
I needed to convert a Tab Seperated Text file into a tabular format as
UPDATE: I managed to get this thing working! Turns out, you NEED to send
I read some documentations about classloaders, but im still not sure where and why
I have some JavaScript form validation I'm using before I send it across to
Scenario: Web Service needed to calculate values and send results back as json. These
In our current project, for some operations we send messages to Database like COMPLETED-Order,STARTED-Request,
I am looking for a way to periodically send some data over all clients

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.