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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:45:32+00:00 2026-05-25T17:45:32+00:00

I am sending a xml string to my web application using httpClient#execute(HttpPost, ResponseHandler) It

  • 0

I am sending a xml string to my web application using httpClient#execute(HttpPost, ResponseHandler)

It works fine when string contains only one tag, but it returns Internal Server Error if two same tags come after root tag. For example:

<Class>
        <Student>Some Elements and Attributes</Student>
        <Student>Some Elements and Attributes</Student>
</Class>

My Code is here for creating xml string:

DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

//root element
Document document = docBuilder.newDocument();
Element rootElement = document.createElement("Class");
document.appendChild(rootElement);

Element student = document.createElement("Student");
rootElement.appendChild(student);

Attr name = document.createAttribute("Name");
name.setValue("");
student.setAttributeNode(name);

//Courses
Element courses = document.createElement("Courses");
Element course = document.createElement("Course");
Attr name = document.createAttribute("Name");
name.setValue("any name");
level.setAttributeNode(name);
courses.appendChild(course);
student.appendChild(courses);

// write the content into xml string
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
StringWriter writer = new StringWriter();
Result result = new StreamResult(writer);
Source source = new DOMSource(document);
transformer.transform(source, result);
writer.close();
xml = writer.toString();

Here is code for sending xml string:

String url = "My URL string";

DefaultHttpClient httpClient = new DefaultHttpClient();   
ResponseHandler<String> res = new BasicResponseHandler();

List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("param1", "student name"));
nameValuePairs.add(new BasicNameValuePair("param2", xmlString));

HttpPost httpPost = new HttpPost(url);
httpPost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

String response = httpClient.execute(httpPost, res);

This code is creating problem. StackTrace is here:

09-21 00:58:29.486: WARN/System.err(7450): org.apache.http.client.HttpResponseException: Internal Server Error
09-21 00:58:29.490: WARN/System.err(7450):     at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:71)
09-21 00:58:29.494: WARN/System.err(7450):     at org.apache.http.impl.client.BasicResponseHandler.handleResponse(BasicResponseHandler.java:59)
09-21 00:58:29.497: WARN/System.err(7450):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:657)
09-21 00:58:29.501: WARN/System.err(7450):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:627)
09-21 00:58:29.501: WARN/System.err(7450):     at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:616)
09-21 00:58:29.505: WARN/System.err(7450):     at com.example.httpandroidtutorial.HttpAndroidTutorialActivity.onClick(HttpAndroidTutorialActivity.java:122)
09-21 00:58:29.509: WARN/System.err(7450):     at android.view.View.performClick(View.java:2461)
09-21 00:58:29.513: WARN/System.err(7450):     at android.view.View$PerformClick.run(View.java:8888)
09-21 00:58:29.517: WARN/System.err(7450):     at android.os.Handler.handleCallback(Handler.java:587)
09-21 00:58:29.517: WARN/System.err(7450):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-21 00:58:29.521: WARN/System.err(7450):     at android.os.Looper.loop(Looper.java:123)
09-21 00:58:29.525: WARN/System.err(7450):     at android.app.ActivityThread.main(ActivityThread.java:4627)
09-21 00:58:29.529: WARN/System.err(7450):     at java.lang.reflect.Method.invokeNative(Native Method)
09-21 00:58:29.533: WARN/System.err(7450):     at java.lang.reflect.Method.invoke(Method.java:521)
09-21 00:58:29.533: WARN/System.err(7450):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
09-21 00:58:29.537: WARN/System.err(7450):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-21 00:58:29.540: WARN/System.err(7450):     at dalvik.system.NativeStart.main(Native Method)

What is the reason for these HttpResponseExceptions?

  • 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-25T17:45:33+00:00Added an answer on May 25, 2026 at 5:45 pm

    The error is coming from your server. The XML may be generated properly, but the server is encountering an error when it gets it. You will need to debug the web application to figure out what is wrong.

    Hope this helps.

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

Sidebar

Related Questions

One of our providers are sometimes sending XML feeds that are tagged as UTF-8
I have a web service that has one method: [WebMethod] public bool SyncUserData(string userxml)
I'm having problem with sending XML-data using HTTP POST to an API. If I
I've got problem sending an array of string as parameter to a web service
I am creating a Web Service using ASP.NET C#. I am sending various data
I'm using a third part web service[WS] in my .Net app. My application is
I created a simple WCF web service that has one method: SubmitTicket(flightticket ft, string
I've created one web service which is of asmx type. And I'm using my
I have web application using SpringFramework3.0.3.RELEASE, developed in Eclipse with m2eclipse plugin and deployed
I'm using System.Xml.XmlElement as a parameter for sending XML data in WCF. Is this

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.