Thanks for your attention Kumar.
Of course I've read the java-docs ... but IMHO is not clear at all, but
I'm not an expert though.
Also one has to read 'saveChanges()' java-doc ... but therefor one has
to actually know that this has to be called when changing the message.
Should it be described somewhere else?
Looking at the source code of 'writeTo()' reveals that 'saveChanges()'
is NOT called every time but only sets a trigger to save it ... is this
a java-doc fuzziness or an deviation of the implementation?
Furthremore why does 'saveRequired()' return 'false' after alterning
the message?
I've seen a lot of code (f.e. in OpenSSO) which looks like ...
if (soapMessage.saveRequired())
soapMessage.saveChanges()
I tried this as well but in my case the changes to the message have not
been persisted into the char array, so using 'writeTo(..)' did not show
them.
Thanks and regards,
Bernhard
Am 4/10/12 12:05 PM, schrieb Kumar Jayanti:
>
> On 10-Apr-2012, at 1:36 PM, Bernhard Thalmayr wrote:
>
>> Hi experts, I've studied the API but I'm still somewhat clueless ...
>> any pointers would be appreciated.
>>
>>
>> If I add some headers to a SOAPMessage like this ...
>>
>> SOAPEnvelope envelope = soapMessage.getSOAPPart().getEnvelope();
>> SOAPHeader header = envelope.getHeader();
>>
>> header.appendChild(someHeader);
>>
>>
>> I 'see' the header using 'soapMessage.getSOAPPart()'
>>
>> However it's somehow not persisted within the acutal char-array, which
>> is used by 'soapMessage.writeTo(Outputstream).
>>
>> So when I use this method the new header is lost...
>>
>> However if I use 'soapMessage.saveChanges()' before calling
>> 'writeTo()' the new header is printed as well.
>>
>> Interestingly enough 'soapMessage.saveRequired()' returns 'false'
>> after adding the new header.
>
> this could be a bug in the RI. Can you file an issue.
>>
>> None of the methods in the API tells me when I have to use
>> 'saveChanges()'.
> Have you looked at the javadoc ?. Are you saying its not clear from the
> javadocs :
>
>
> saveChanges
>
> public abstract void*saveChanges*()
> throwsSOAPException <http://docs.oracle.com/javase/6/docs/api/javax/xml/soap/SOAPException.html>
>
> Updates this |SOAPMessage| object with all the changes that have
> been made to it. This method is called automatically when
> |writeTo(OutputStream)|
> <http://docs.oracle.com/javase/6/docs/api/javax/xml/soap/SOAPMessage.html#writeTo(java.io.OutputStream)>
> is called. However, if changes are made to a message that was
> received or to one that has already been sent, the method
> |saveChanges| needs to be called explicitly in order to save the
> changes. The method |saveChanges| also generates any changes that
> can be read back (for example, a MessageId in profiles that support
> a message id). All MIME headers in a message that is created for
> sending purposes are guaranteed to have valid values only after
> |saveChanges| has been called.
>
> In addition, this method marks the point at which the data from all
> constituent |AttachmentPart| objects are pulled into the message.
>
>
>
> *Throws:*
> ||SOAPException|| - if there was a problem saving changes to
> this message.
> |SOAPException
> <http://docs.oracle.com/javase/6/docs/api/javax/xml/soap/SOAPException.html>|
>
> ------------------------------------------------------------------------
>
>
>>
>> TIA,
>> Bernhard
>>
>> --
>> Painstaking Minds
>> IT-Consulting Bernhard Thalmayr
>> Herxheimer Str. 5, 83620 Vagen (Munich area), Germany
>> Tel: +49 (0)8062 7769174
>> Mobile: +49 (0)176 55060699
>>
>> bernhard.thalmayr_at_painstakingminds.com
>> <mailto:bernhard.thalmayr_at_painstakingminds.com> - Solution Architect
>>
>> This e-mail may contain confidential and/or privileged information.If
>> you are not the intended recipient (or have received this email in
>> error) please notify the sender immediately and delete this e-mail.
>> Any unauthorized copying, disclosure or distribution of the material
>> in this e-mail is strictly forbidden.
>
--
Painstaking Minds
IT-Consulting Bernhard Thalmayr
Herxheimer Str. 5, 83620 Vagen (Munich area), Germany
Tel: +49 (0)8062 7769174
Mobile: +49 (0)176 55060699
bernhard.thalmayr_at_painstakingminds.com - Solution Architect
This e-mail may contain confidential and/or privileged information.If
you are not the intended recipient (or have received this email in
error) please notify the sender immediately and delete this e-mail. Any
unauthorized copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.