Purpose of MimeHeaders argument in adding attachments?

From: Karr, David <>
Date: Mon, 7 Jun 2004 16:13:53 -0700

(Sorry for the multi-post, but activity on saaj-users seems almost

I'm using WebLogic 8.1SP2, which is using SAAJ 1.1.1, I believe.

I could use some help understanding exactly the purpose and use of the
MimeHeaders argument to "MessageFactory.createMessage(MimeHeaders,
InputStream)". I'll describe the series of simple test cases I went
through, and perhaps someone could give me some background on what I'm
seeing here.

If my stream contains a message without an attachment, then the
MimeHeaders argument can be null without causing a complaint. The
result doesn't appear to be MIME-encoded.

If I then change my test case so the only change is making it add a
simple XML attachment (sending "text/xml" as the content-type of the
attachment), then I get an NPE, because it's apparently trying to read
the MimeHeaders object that I passed (which was null).

If I then just send it an "empty" MimeHeaders object (created, but no
headers added to it), that fails, saying there was no "Content-Type"
header. I'm guessing this is referring to the content-type of the
entire message, and not the attachment.

Then, if I add a header for "Content-Type" ("text/xml") to the
MimeHeaders object that I passed, then it appears to be fine. I wrote
out the resulting SOAPMessage to a string, and I see that there is a
"Content-Type" header in two places in the MIME-encoded message, one at
the "top", and one associated with the attachment.

In our actual code base, I have code in an "intermediary" web service
that takes a stream representing a SOAP request, but it is presently
passing "null" for the MimeHeaders argument. Will that break as soon as
someone sends a SOAP request that has an attachment?

In summary, I could use a little more understanding of the real purpose
of that MimeHeaders argument, and how it is used both with and without
the presence of attachments.

To unsubscribe, e-mail:
For additional commands, e-mail: