users@saaj.java.net

Various SAAJ Issues/Questions

From: Brian Joh <brianj_at_twitter.com>
Date: Fri, 5 Aug 2011 00:03:38 -0400

Hello,

Excuse me if this is not the appropriate mailing list....


For several months, we've been working with the SAAJ package built into the
Sun JDK 6 to parse incoming SOAP messages with attachments. We found some
issues, so recently we've been using and fixing the problems in the SAAJ
Standard Implementation.

1. If the "start" parameter in the document Content-Type is not surrounded
by angle brackets, the root part will not be found, and an Exception will be
thrown. This issue is already open in your JIRA as SAAJ-59 and a patch for
this problem exists (but not yet applied), so I won't provide our
workaround. However, please see the attached "missing-angle-brackets.txt"
for a simple example of the problem. And I believe this is not valid MIME
but we have seen this problem quite a bit.

2. This next problem only occurs when "saaj.mime.optimization" is turned
off (so Javamail is used for MIME parsing), but the problem is in SAAJ not
JavaMail. When "start" is specified in the document's Content-Type , and
one of the parts does not have a Content-ID header, a NullPointerException
will be thrown. That is, when the "start" is specified, the code assumes
each part has a Content-ID. We don't see this problem often because usually
in a multipart-related each part will has a Content-ID to allow the parts to
be "related". However, MIME parts can also be referenced through
Content-Location instead of Content-ID, and that's when the problem can crop
up Please note again that this code path is only followed when
"saaj.mime.optimization" is set to false, but the problem is in the SAAJ
code, not JavaMail. I've attached an example in "missing-cid.txt" and a
patch in "MessageImpl.java.missing-cid.patch".

3. An Exception will be thrown when "saaj.mime.optimization" is set to true
and there are extra whitespace characters after a MIME boundary (and before
the CR LF). The example is in "extra-boundary-white-space.txt". We fixed
it by setting "saaj.mime.optimization" to false (and using JavaMail for MIME
parsing), so I don't have a patch.


The next few issues were identified while parsing examples from various
notes/specs, such as http://www.w3.org/TR/SOAP-attachments. They are less
critical, because we haven't seen the problems with real SOAP clients yet,
so I haven't created fixes. But the operative word is "yet".

1. In the document Content-Type, an exception is thrown when the "type"
parameter's value (e.g text/xml) is not surrounded by quotes. The code sees
the "/" as a delimiter and interprets the value as three separate tokens
("text" "/" "xml" ). Please see the attached "missing-quotes.txt" for an
example. I'm not sure if this is valid MIME or not.

2. The Content-Type is not interpreted properly when upper case characters
are used (e.g "Multipart/Related"). I've concocted an example in
"mixed-case-content-type.txt", where the "start" parameter in the
Content-Type is ignored. This causes an Exception when the first part is not
the start/SOAP part.

3. In folded or wrapped MIME headers, only the first line is being
recognized In the attached "folded-content-type.txt", I've concocted
another example where the start parameter in the Content-Type is ignored.
And again this causes an Exception when the SOAP part is not the first part.

If you prefer, I can also submit these issues into your JIRA.


Finally, I have some questions:

1. From what I understand, the SAAJ Standard Implementation is incorporated
into many projects. It's incorporated into Project Metro, which is used by
Glassfish, which then gets pulled into the OpenJDK. And I can tell that the
SUN JDK SAAJ version is very similar, maybe even almost identical, to the
SAAJ Standard Implementation, but they are not totally the same. So what is
the relationship between SAAJ standard implementation and the SAAJ version
packaged in the SUN JDK? And how soon can we expect bug fixes made in the
SAAJ Standard Implementation to be pulled into SUN JDK releases and/or
OpenJDK releases. How soon can we expect a stable stand-alone release of
the Standard Implementation that incorporates these fixes?

2. Since SAAJ is built into Sun JDK 6, we've been dropping the SAAJ
Standard Implementation into our lib/endorsed directory. And we also
overrode the SAAJ implementation by setting properties such as
"javax.xml.soap.SOAPFactory", "javax.xml.soap.MessageFactory",
"javax.xml.soap.SOAPConnectionFactory". Are there any other ways to
incorporate the SAAJ Standard Implementation into a JDK 6/7 application?

Keep up the good work and thank you!

Brian Joh
Software Engineer
Twitter Mobile
http://twitter.com/brianwjoh <http://www.twitter.com/brianwjoh>