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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T03:50:17+00:00 2026-06-12T03:50:17+00:00

I have an API which I want to use to fetch data. For fetching

  • 0

I have an API which I want to use to fetch data. For fetching data I have to send a request in XML format and response will be sent in XML. Does anyone have any example how to send a request using Java and how to decode the response in java.

  • 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-12T03:50:18+00:00Added an answer on June 12, 2026 at 3:50 am

    Well i have just what you wanted… but i would ask you to use the following APIs …

    • JAXP and JAXB
    • Castor

    – The below code snippet method accepts the url of the web-server and the xmlQuery

    – I have used the NameValuePair to send the XML request

    – Please replace the MySSLSocketFactory.getNewHttpClient(); with an Http Client, i have used this it needs a custom certificate to access this site.`

    Here is the code from my Project, that sends an XML req and gets back an XML resp :

    public String postData(String url, String xmlQuery) {
    
            final String urlStr = url;
            final String xmlStr = xmlQuery;
            final StringBuilder sb = new StringBuilder();
    
            Thread t1 = new Thread(new Runnable() {
    
                public void run() {
    
                    HttpClient httpclient = MySSLSocketFactory.getNewHttpClient();
    
                    HttpPost httppost = new HttpPost(urlStr);
    
                    try {
    
                        List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(
                                1);
                        nameValuePairs.add(new BasicNameValuePair("xml", xmlStr));
    
                        httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
    
                        HttpResponse response = httpclient.execute(httppost);
    
                        Log.d("Vivek", response.toString());
    
                        HttpEntity entity = response.getEntity();
                        InputStream i = entity.getContent();
    
                        Log.d("Vivek", i.toString());
                        InputStreamReader isr = new InputStreamReader(i);
    
                        BufferedReader br = new BufferedReader(isr);
    
                        String s = null;
    
                        while ((s = br.readLine()) != null) {
    
                            Log.d("YumZing", s);
                            sb.append(s);
                        }
    
                        Log.d("Check Now", sb + "");
    
                    } catch (ClientProtocolException e) {
    
                        e.printStackTrace();
                    } catch (IOException e) {
                        e.printStackTrace();
                    } 
                }
    
            });
    
            t1.start();
            try {
                t1.join();
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
    
            System.out.println("Getting from Post Data Method " + sb.toString());
    
            return sb.toString();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several GWT Maps API JavaScriptObjects (LatLng, Polyline) which I want to send
I have taken a look at the PMD api which I want to use
i have created the site in which i want to use bing search API
I have an XML response from the Google Directions API and want to cache
I have an api which takes uni code data as c character array and
I have a REST api which dumps some json data (user info, etc). Now
I'm developing an API which will also have an authentication/authorization component. Anybody, regardless of
I want to have my API controller use SSL, so I added another listen
what i want to do is : i have an CRM API which produce
I have api keys which i don't want to show in public but still

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.