aspose file tools*
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 Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "org.xml.sax.SAXParseException" Watch "org.xml.sax.SAXParseException" New topic
Author

org.xml.sax.SAXParseException

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();
jpegAttach.setContent(fis,"image/jpeg");
message.addAttachmentPart(jpegAttach);

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

I am using AXIS also.


The XML which is generated from this is given below


------=_Part_0_17876004.1140606394046

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="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Body/>
</soapenv:Envelope>

------=_Part_0_17876004.1140606394046

Content-Type: image/jpeg

Content-Transfer-Encoding: binary

Content-Id: <E54FA2EDDCB0638BECAB9DC415090341>



����


Please advise what can be wrong here.
Thanks,
kundan


SCJP1.4,SCBCD,SCEA,CNA
Failures are practice shoots for success.
Peer Reynders
Bartender

Joined: Aug 19, 2005
Posts: 2922
    
    5
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
 
wood burning stoves
 
subject: org.xml.sax.SAXParseException