[jdom-interest] XMLOutputter not posting doc to OutputStream

Clif Bate cjbate at yahoo.com
Mon Sep 30 14:21:50 PDT 2002


Hello,
  This question may be rather basic to those more
experienced, however I have not been able to work my
way out of this.
  I have a class that is building an XML doc using
JDOM and then am trying to post it to a URL.  I have
used the XMLOutputter to output the doc to the
System.out to verify the doc is correct, and it is.

  However, when then trying to post it to a URL it
does not seem to be sending anything.  I have an the
receiver set to email me the data received.  

Here is the code snipplets:

    private XMLOutputter oOutputter = new
XMLOutputter("  ", true);
oOutputter.output(p_oDoc, System.out); // this works

HttpURLConnection conn = (HttpURLConnection)
               url.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "text/xml");
conn.setUseCaches(false);
OutputStream out = conn.getOutputStream();
InputStream in = conn.getInputStream();
    
oOutputter.output(p_oDoc, out); 
out.flush();
out.close();

// Read the response
Document response = null;
 try {
       SAXBuilder parser = new SAXBuilder();
       response = parser.build(in);
       in.close();
       conn.disconnect();
    } catch (IOException ioe) {
            logger.debug("Error reading the response
document: " + ioe);
         } catch (JDOMException jde) {
            logger.debug("Error building the response
document: " + jde);
         }


I am successfully getting a reply from where I am
posting to, and able read the XML in the response. 
Its just that it tells me that nothing was received at
the URL.

Any help would be greatly appreciated.

Thanks,
Clif


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com



More information about the jdom-interest mailing list