Re: Upgrade to Java 1.6 killed my app!

From: V B Kumar Jayanti <Vbkumar.Jayanti_at_Sun.COM>
Date: Thu, 22 Mar 2007 15:40:22 +0530

Hi Bob,

   Part of the problem comes from the Original Javadoc for
CreateMessage that existed from the begining of SAAJ API's :



public abstract SOAPMessage <> *createMessage*()
                                   throws SOAPException <>

Creates a new |SOAPMessage| object with the default |SOAPPart|,
|SOAPEnvelope|, |SOAPBody|, and |SOAPHeader| objects. Profile-specific
message factories can choose to prepopulate the |SOAPMessage| object
with profile-specific headers.

So when using DYNAMIC_SOAP_PROTOCOL, the createMessage() would not know
what kind of an envelope has to be created. If the javadoc had not
talked about creating a default SOAPEnvelope then i guess we had a
chance to do something better,


Because someone could just write the following 3 lines of code with
SAAJ 1.2 API :

        MessageFactory mf = MessageFactory.newInstance();
        SOAPMessage msg = mf.createMessage();

And the expected result as per the spec was :


Now with DYNAMIC protocol this becomes ambiguous and hence the SAAJ 1.3
spec states that an UnSupportedOperationException be thrown. But the
use of DYNAMIC_SOAP_PROTOCOL makes the SAAJ runtime capable of
accepting both SOAP 1.1 and SOAP 1.2 messages, especially when you make


syg6 wrote:

>Hello, thanks for your response,
>I would like to be able to parse both SOAP 1.1 and 1.2. So if I use
>DYNAMIC_SOAP_PROTOCOL I must use createMessage(MIMEHeaders, InputStream).
>But I don't have MIMEHeaders or an InputStream, I only have the string,
>So is the only way to do this to get the uri of the namespace associated
>with the Envelope and put an 'if'? IOW:
>if (uri.equals('')
> factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL);
>else factory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL);
>This seems kind of kludgy. What happens when SOAP 1.3 comes out? I would
>think that the existence of a DYNAMIC_SOAP_PROTOCOL constant would indicate
>that it recognizes the document ... you know, dynamically?
>Anything other than this kludgy 'if' that I can do?
>V B Kumar Jayanti wrote:
>>If you need a message Factory that should work for both SOAP 1.1 and 1.2
>>envelopes then you need to do the following :
>>MessageFactory factory =
>>But NOTE that factory.createMessage() would then throw