ws-soap-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Yang <Andrew.X.Y...@Sun.COM>
Subject How to get SOAP Envelope from SOAP with Attachment Message (MIME Type)??
Date Fri, 23 Aug 2002 18:31:56 GMT
I have used following code to get SOAP Envelope from HTTPServlet Request:

--------------------------------------------------
if(request.getContentLength() > 0)
{
   try
   {
      BufferedReader reader = req.getReader();

      javax.xml.parsers.DocumentBuilder xdb =
                   org.apache.soap.util.xml.XMLParserUtils.getXMLDocBuilder();
      org.w3c.dom.Document doc = xdb.parse(new
                                             org.xml.sax.InputSource(reader));
      org.apache.soap.Envelope env = org.apache.soap.Envelope.unmarshall(
                                             doc.getDocumentElement());
      ... ...
   }
   ... ...
}

.. ... // process the Envelope env
--------------------------------------------------

Now I need to process "SOAP With Attachment" message transmitted via HTTP. The message was
sent as

--------------------------------------------------
org.apache.soap.messaging.Message msg = new
                       org.apache.soap.messaging.Message();
if( attachmentFlag ) 
{
   ... ... // get attachment, assume it is a text file.

   MimeBodyPart mbpAttach = new MimeBodyPart();
   mbpAttach.setText(sbu.toString());
   mbpAttach.setHeader("Content-ID", "the-attachment");
   msg.addBodyPart(mbpAttach);
}

msg.send(new java.net.URL(hostURL), URI, envelope);
-------------------------------------------------

If the attachmentFlag is off, I got the Envelope and the program runs fine.

However, if the attachmentFlag is on, the client does indeed sent the MIMI message over HTTP,
but the server-side program does not get correct Envelope. The error message is:
SwaHttpReceiveServlet: Exception: 
   org.xml.sax.SAXParseException: Document root element is missing.

I guess I have to somehow disassemble the MIME Message, seperate the SOAP part and the attachment
part.

Has anyone had similar problem? How did you solve it? What are possible solutions?

Thanks you in advance!

Andy




Mime
View raw message