Hi Bob,
Part of the problem comes from the Original Javadoc for
CreateMessage that existed from the begining of SAAJ API's :
--------------
createMessage
public abstract SOAPMessage <
http://java.sun.com/j2ee/1.4/docs/api/javax/xml/soap/SOAPMessage.html> *createMessage*()
throws SOAPException <
http://java.sun.com/j2ee/1.4/docs/api/javax/xml/soap/SOAPException.html>
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();
msg.writeTo(System.out);
And the expected result as per the spec was :
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="
http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Header/><SOAP-ENV:Body/></SOAP-ENV:Envelope>
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
a SOAPConnection.call()
regards,
kumar
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,
>pXml.
>
>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('http://www.w3.org/2003/05/soap-envelope/')
> 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?
>
>Thanks,
>Bob
>
>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 =
>>MessageFactory.newInstance(SOAPConstants.DYNAMIC_SOAP_PROTOCOL);
>>
>>But NOTE that factory.createMessage() would then throw
>>UnsupporteOperationException.
>>
>>
>>
>
>
>