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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:16:58+00:00 2026-05-24T16:16:58+00:00

I want to have an application which parses various RSS feeds and send the

  • 0

I want to have an application which parses various RSS feeds and send the information to a remote server. The information is sent in xml format via http. At first I tried to deploy this application on my own server, so I send the xml using the method shown in this tutorial by Java Tips. Here is my code which is replicated from the example:

First Method

    String strURL = "http://localhost/readme/readme_xml";
    String strXMLFilename = "output.xml";
    File input = new File(strXMLFilename);


    PostMethod post = new PostMethod(strURL);
    post.setRequestEntity(new InputStreamRequestEntity(
            new FileInputStream(input), input.length()));
    post.setRequestHeader(
            "Content-type", "text/xml; charset=ISO-8859-1");
    HttpClient httpclient = new HttpClient();
    try {

        int result = httpclient.executeMethod(post);            
        System.out.println("Response status code: " + result);            
        System.out.println("Response body: ");
        System.out.println(post.getResponseBodyAsString());            
    } finally {
        post.releaseConnection();
    }

This works perfectly (I even tested using a remote server outside the localhost). Then, somehow I cant use my own server to deploy this application, so I decided to migrate to Google Apps Engine. One thing about it, as we know it, is that not all libraries are allowed in the environment. So I try another method shown in ExampleDepot.com (I can’t find where the exact url though) as below:

Second Method

try {
           /* fill up this url with the remote server url */
            URL url = new URL("http://localhost/readme/readme_xml");
            FileReader fr = new FileReader("output.xml");
            char[] buffer = new char[1024*10];
            int len = 0;
            if ((len = fr.read(buffer)) != -1){
            /* send http request to remote server */
                URLConnection conn = url.openConnection();
                conn.setRequestProperty("Content-Type","text/xml;charset=ISO-8859-1"); /* need to specify the content type */
                conn.setDoOutput(true);
                conn.setDoOutput(true);
                PrintWriter pw = new PrintWriter(conn.getOutputStream());
                pw.write(buffer, 0, len);
                pw.flush();
                /* receive response from remote server*/
                BufferedReader bf = new BufferedReader(new InputStreamReader(conn.getInputStream()));
                String input = null;
                while ((input = bf.readLine()) != null){
                    System.out.println(input);
                }
            }

        } catch (MalformedURLException e) {
                e.printStackTrace();
        } catch (FileNotFoundException e) {
                e.printStackTrace();
        } catch (IOException e) {
                e.printStackTrace();
        }
    }

The second method though, doesn’t work and gives the following error (I use SimpleXMLElement (php) object to parse xml in the remote hosting):

Error message from remote server

Here’s the php code from the remote server (In here, I just want the SimpleXMLElement to parse the xml without doing anything else fancy for now)

$xml = new SimpleXMLElement('php://input', NULL, TRUE);
   foreach ($xml -> attributes() as $name => $val){
   echo "[".$name."] = ".$val."\n";
   }

I thought the cause of this problem is the malfunction xml file (because the eclipse IDE indicates there’s error of “invalid byte 1 of 1-byte utf-8 sequence”). Then I use the same exact input xml file to the first method, but it still works perfectly.

So is there any adjustment that I need to make to the second method? Or is there any other method that I can use to send xml file to remote server? Let me know if I need to add some other details. Thanks for your help.


NOTE: I actually solved this problem by using the solution given in the comments. I didn’t use approaches suggested in the answers, even though those answers are pretty useful. So, I didn’t select the best answer out of those answers given. Nonetheless, I still appreciate all of your helps, thus deserve my upvote. Cheers!

  • 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-24T16:17:01+00:00Added an answer on May 24, 2026 at 4:17 pm

    I guess you need to change the content type to multipart/form-data. See an already answered question in detailed. The file upload is discussed at the bottom of this example

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

Sidebar

Related Questions

I have a server application which I want to protect from being stopped by
I have an application in which I want to authenticate a user from a
We have created an application which we want to run in a 64 bit
I have an application in which there is a form which I want to
I have an iPhone application which in which I want to perform a method
i have website of application which sells applications online.on the home page i want
I have written a application which runs in the background. I want to write
i have created an application which show data from user current location. I want
I just want to know that can i make an application which have some
I have written an application in which I want to convert a .jpg image

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.