This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes org.xml.sax.SAXParseException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "org.xml.sax.SAXParseException" Watch "org.xml.sax.SAXParseException" New topic


kundan varma
Ranch Hand

Joined: Mar 08, 2004
Posts: 322
Hi All,
I am having "org.xml.sax.SAXParseException: Document root element is missing" . The jaxp parser is giving me this error....
I am generating XML from this code
private void setAttachment() throws SOAPException,FileNotFoundException,IOException {
MessageFactory mf = MessageFactory.newInstance();
SOAPMessage message = mf.createMessage();
File imgFile = new File("D:\\Pics\\Me\\Image(067).jpg");
FileInputStream fis = new FileInputStream(imgFile);
String path = imgFile.getAbsolutePath();
//Image image = Toolkit.getDefaultToolkit().createImage(path);
AttachmentPart jpegAttach = message.createAttachmentPart();

File file = new File("c:\\test\\Attachment.xml");
path = file.getAbsolutePath();
FileOutputStream fos = new FileOutputStream(path);

I am using AXIS also.

The XML which is generated from this is given below


Content-Type: text/xml; charset=UTF-8

Content-Transfer-Encoding: binary

Content-Id: <B27FA6C4D8C823D8C4E0D436AE26D03E>

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="" xmlns:xsd="" xmlns:xsi="">


Content-Type: image/jpeg

Content-Transfer-Encoding: binary

Content-Id: <E54FA2EDDCB0638BECAB9DC415090341>


Please advise what can be wrong here.

Failures are practice shoots for success.
Peer Reynders

Joined: Aug 19, 2005
Posts: 2922
Originally posted by kundan varma:
The XML which is generated from this is given below

That's not XML. It's a MIME envelope where the first part contains the SOAP message (which is the XML). That is what is supposed to happen for "SOAP with Attachments" which have to be treated separately from regular SOAP messages.

You may want to have a look at the end of
Java Web Services in a Nutshell Chapter 3: SAAJ
"SOAP Messages and MIME Headers"
"SOAP with Attachments"
and Sending SOAP attachments with JAX-RPC
I agree. Here's the link:
subject: org.xml.sax.SAXParseException
Similar Threads
No response on server-side
WSAD 5.1.1 SOAP RPC return type of Object[]
encoding in java
problem with perl web services and java client
.Net Client for Axis Web services