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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:55:53+00:00 2026-06-12T18:55:53+00:00

So I have the following code: public void SendToApplication(HttpServletRequest request) throws IOException, TransformerException {

  • 0

So I have the following code:

    public void SendToApplication(HttpServletRequest request) throws IOException, TransformerException {

        BufferedReader br = new BufferedReader(new FileReader(new File("CreatePoll.xml")));
        String line;
        StringBuilder sb = new StringBuilder();

        while((line=br.readLine())!= null) sb.append(line.trim());

        DefaultHttpClient httpClient = new DefaultHttpClient();
        HttpPost postRequest = new HttpPost("http://localhost:8080/cs9322.simple.rest.doodle/rest/polls/comment");
        StringEntity input = new StringEntity(sb.toString());
        input.setContentType("text/xml");
        postRequest.setEntity(input);
        HttpResponse response = httpClient.execute(postRequest);
        HttpEntity entity = response.getEntity();

    }

Which reads a XML file (CreatePoll.xml),

<Comment xmlns:xs="http://localhost:8080/cs9322.simple.rest.doodle/CommentSchema">
  <Poll_ID>2</Poll_ID>
  <Name>Bob</Name>
  <Text>testing junk</Text>
  <Timestamp>2012-10-14T12:37:04</Timestamp>
</Comment>

And posts it to a web service, the problem I am having now is trying to receive the XML response from the web service after sending that. XML I am meant to receive is:

<comment>
    <address>
    </address>
</comment>

Can someone help me out here it’d be much appreciated!

  • 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-12T18:55:54+00:00Added an answer on June 12, 2026 at 6:55 pm

    If you utilize the Apache Commons IO, then you can use the IOUtils class to read the input stream from the HttpEntity. Example using the twitter Rest API:

    DefaultHttpClient httpClient = new DefaultHttpClient();
    HttpPost postRequest = new HttpPost("http://search.twitter.com/search.atom?q=elkstein&count=5");
    HttpResponse response = httpClient.execute(postRequest);
    
    HttpEntity entity = response.getEntity();
    String body = IOUtils.toString(entity.getContent(), "UTF-8");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In a ViewHandlerWrapper-implementation I have following code: public void renderView(FacesContext context, UIViewRoot viewToRender) throws
I have the following code: public void run() { try { logger.info(Looking for new
I have the following code: public void setupScreen() { view.runOnUiThread(new Runnable() { public void
SO I have the following code public void rand(int N){ double[]x=new double[N]; double[]y=new double[N];
I have the following code: public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.screen_database); db=new DBAdapter(this);
I have following code: public static void ProcessStep(Action action) { //do something here if
I have following code public class TEST { public static void main(String arg[]){ try
I have the following code: public void disconnect() { running = false; if(thread !=
I have the following code: public void Dispose() { bool append = true; using(var
I have the following code: public void BeginConvert(object data) { ConverterData cObject = (ConverterData)data;

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.