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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:23:47+00:00 2026-06-13T19:23:47+00:00

I am sending some XML as a SOAP request, but when that XML contains

  • 0

I am sending some XML as a SOAP request, but when that XML contains the characters & or <, I get an empty response. Here is some relevant code:

String myXml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
               "<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\">" +
                   "<soap12:Body>" +
                      "[XML THAT DOESN'T WORK WITH '&' AND '<']" +
                   "</soap12:Body>" +
               "</soap12:Envelope>";

HttpPost httpPost = new HttpPost("http://website.com");
StringEntity stringEntity = new StringEntity(myXml, HTTP.UTF_8);
stringEntity.setContentType("text/xml");
httpPost.setHeader("Content-Type", "application/soap+xml;charset=UTF-8)";
httpPost.setEntity(stringEntity);

HttpClient httpClient = new DefaultHttpClient();
BasicHttpResponse httpResponse = (BasicHttpResponse) httpClient.execute(httpPost);

HttpEntity httpEntity = httpResponse.getEntity();
InputStream inputStream = responseEntity.getContent();
//Checking inputStream here reveals that it is empty (not null) when xml has '&' or '<'

I thought it might be because of these predefined entities, but every other special character that I tried it with caused no problems.

Do you know why this is, and how I can go about fixing it (other than just catching the specific cases of & and <)?

I found a suggested solution to do

httpPost.setEntity(new UrlEncodedFormEntity(List<NameValuePair>, String encoding))

But I don’t have NameValuePairs, just a StringEntity.

  • 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-13T19:23:48+00:00Added an answer on June 13, 2026 at 7:23 pm

    I thought it might be because of these predefined entities

    Exactly. Those should be escaped for values, so the correct version of the data would be:

    [XML THAT DOESN'T WORK WITH '&amp;' AND '&lt;']
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am sending a SOAP POST that returns some xml. I've been testing on
I'm sending XML request to some server and getting some response data from it
Here is some code of an XSD that is VALID in XML Spy but
Is it possible to get the XML generated by SOAP Client before sending it
Is there some way when sending this message to specify that I rather have
We have some third parties that are sending us traffic and have asked us
I have written some jQuery ajax code where I am sending a request to
One desktop application needs to get some services from server. For example sending some
I have a page that is making an XML POST-Request to an URL on
I have a piece of xml that contains optional non-enumerated elements, so schema validation

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.