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

  • Home
  • SEARCH
  • 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 7641811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:01:11+00:00 2026-05-31T09:01:11+00:00

I need to send an xml file using http post in android. I am

  • 0

I need to send an xml file using http post in android. I am new to this. Where i put the xml in the android and how to send it using the code.

The sample of the xml looks like this

http://api.ean.com/ean-services/rs/hotel/v3/list?
    minorRev=[current minorRev #]
    &cid=55505
    &apiKey=[xxx-yourOwnKey-xxx]
    &customerUserAgent=[xxx]
    &customerIpAddress=[xxx]
    &locale=en_US
    &currencyCode=USD
    &xml=
    <HotelListRequest>
    <city>Seattle</city>
    <stateProvinceCode>WA</stateProvinceCode>
    <countryCode>US</countryCode>
    <arrivalDate>08/01/2012</arrivalDate>
    <departureDate>08/03/2012</departureDate>
    <RoomGroup>
    <Room>
    <numberOfAdults>2</numberOfAdults>
     </Room>
     </RoomGroup>
     <numberOfResults>1</numberOfResults>
         <supplierCacheTolerance>MED_ENHANCED</supplierCacheTolerance>
         </HotelListRequest>
  • 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-31T09:01:14+00:00Added an answer on May 31, 2026 at 9:01 am

    Creating xml file

    DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
     dbfac.setNamespaceAware(true);
     DocumentBuilder docBuilder = null;
     try {
        docBuilder = dbfac.newDocumentBuilder();
    } catch (ParserConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
     DOMImplementation domImpl = docBuilder.getDOMImplementation();
     Document doc = domImpl.createDocument("http://coggl.com/InsertTrack","TrackEntry", null);
     doc.setXmlVersion("1.0");
     doc.setXmlStandalone(true);
    
     Element trackElement = doc.getDocumentElement();
    
     Element CompanyId = doc.createElement("CompanyId");
     CompanyId.appendChild(doc.createTextNode("1"));
     trackElement.appendChild(CompanyId);
    
     Element CreatedBy = doc.createElement("CreatedBy");
     CreatedBy.appendChild(doc.createTextNode("6"));
     trackElement.appendChild(CreatedBy);
    
     Element DepartmentId = doc.createElement("DepartmentId");
     DepartmentId.appendChild(doc.createTextNode("4"));
     trackElement.appendChild(DepartmentId);
    
     Element IsBillable = doc.createElement("IsBillable");
     IsBillable.appendChild(doc.createTextNode("1"));
     trackElement.appendChild(IsBillable);
    
     Element ProjectId = doc.createElement("ProjectId");
     ProjectId.appendChild(doc.createTextNode("1"));
     trackElement.appendChild(ProjectId);
    
     Element StartTime = doc.createElement("StartTime");
     StartTime.appendChild(doc.createTextNode("2012-03-14 10:44:45"));
     trackElement.appendChild(StartTime);
    
     Element StopTime = doc.createElement("StopTime");
     StopTime.appendChild(doc.createTextNode("2012-03-14 11:44:45"));
     trackElement.appendChild(StopTime);
    
     Element TaskId = doc.createElement("TaskId");
     TaskId.appendChild(doc.createTextNode("3"));
     trackElement.appendChild(TaskId);
    
     Element TotalTime = doc.createElement("TotalTime");
     TotalTime.appendChild(doc.createTextNode("1"));
     trackElement.appendChild(TotalTime);
    
     Element TrackDesc = doc.createElement("TrackDesc");
     TrackDesc.appendChild(doc.createTextNode("dello testing"));
     trackElement.appendChild(TrackDesc);
    
     Element TrackId = doc.createElement("TrackId");
     TrackId.appendChild(doc.createTextNode("0"));
     trackElement.appendChild(TrackId);
    
     TransformerFactory transfac = TransformerFactory.newInstance();
     Transformer trans = null;
    try {
        trans = transfac.newTransformer();
    } catch (TransformerConfigurationException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
     trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
     trans.setOutputProperty(OutputKeys.INDENT, "yes");
    
     //create string from xml tree
     StringWriter sw = new StringWriter();
     StreamResult result = new StreamResult(sw);
     DOMSource source = new DOMSource(doc);
     try {
        trans.transform(source, result);
    } catch (TransformerException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
     String xmlString = sw.toString();
    
    //posting xml file to server
    
     DefaultHttpClient httpClient = new DefaultHttpClient();
    
     HttpPost httppost = new HttpPost("http://192.168.0.19:3334/cogglrestservice.svc/InsertTrack");     
     // Make sure the server knows what kind of a response we will accept
     httppost.addHeader("Accept", "text/xml");
     // Also be sure to tell the server what kind of content we are sending
     httppost.addHeader("Content-Type", "application/xml");
    
     try
     {
     StringEntity entity = new StringEntity(xmlString, "UTF-8");
     entity.setContentType("application/xml");
     httppost.setEntity(entity);
    
     // execute is a blocking call, it's best to call this code in a thread separate from the ui's
     HttpResponse response = httpClient.execute(httppost);
    
     BasicResponseHandler responseHandler = new BasicResponseHandler();
        String strResponse = null;
        if (response != null) {
            try {
                strResponse = responseHandler.handleResponse(response);
            } catch (HttpResponseException e) {
                e.printStackTrace();  
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        Log.e("WCFTEST", "WCFTEST ********** Response" + strResponse);    
    
    
     }
     catch (Exception ex)
     {
     ex.printStackTrace();
     }
     Toast.makeText(EditTask.this, "Xml posted succesfully.",Toast.LENGTH_SHORT).show();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a sample xml file that looks like this: <Books> <Category Genre=Fiction BookName=book_name
I have an XML file which I need to parse using PHP and send
This may sound ridiculous but I need to send something like <policy-file-request/> followed by
HI I have an xml file with 500KB size which i need to send
I need to send this XML <?xml version=1.0 encoding=UTF-8?> <gate> <country>NO</country> <accessNumber>1900</accessNumber> <senderNumber>1900</senderNumber> <targetNumber>4792267523</targetNumber>
I have got following code witch are sending xml file on HTTP protocol and
When parsing XML like below, does book.xml need to be a static file of
I need to encrypt an XML file, send it to another location and decrypt
I use: wget --no-check-certificate --http-user=user --http-password=secret --header=Content-Type:text/xml --post-file=request.xml https://mydominain.com/xml to send an xml request.
I need to load xml file from specified url using javascript. Here is what

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.