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()
throws SOAPException
Updates this SOAPMessage object with all the changes that have been made to it. This method is called automatically when writeTo(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
>
> 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 - 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.