OK I tried to follow but feel dumber than ever.
<div><br></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); ">The whole point of the library </span><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); ">is that you don't (usually) work with DOM Elements, etc. You work with</span></div>
<div><span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); ">XMLObject provider instances. </span></div></blockquote>
<span class="Apple-style-span" style="color: rgb(34, 34, 34); font-family: arial, sans-serif; ">and </span><br><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; ">
<span class="Apple-style-span" style="font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); ">So you build an Envelope XMLObject, then </span><span class="Apple-style-span" style="font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); ">build a Header XMLObject and add it to the Envelope</span></div>
</div><div style="color: rgb(34, 34, 34); font-family: arial, sans-serif; "><span class="Apple-style-span" style="font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); "><br></span></div></blockquote><font class="Apple-style-span" color="#222222" face="arial, sans-serif">I lose the bubble right there. I'm trying to add SAML headers to a DOM document whose body already exists and whose header is initially empty. But everything I try discards the existing DOM.<br>
</font><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;"><div><span class="Apple-style-span" style="font-size: 13px; background-color: rgba(255, 255, 255, 0.917969); "><br></span></div></blockquote><font class="Apple-style-span" color="#222222" face="arial, sans-serif">I tried following those instructions literally like this:</font><div>
<font class="Apple-style-span" color="#222222" face="arial, sans-serif"><div><span class="Apple-tab-span" style="white-space:pre">                </span>Element soapEnvelope = document.getDocumentElement();</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Element soapHeader = DOMUtil.getSoapHeader(soapEnvelope);</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>Element soapBody = DOMUtil.getSoapBody(soapEnvelope);</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">                </span>Envelope envelope = (Envelope) Configuration.getBuilderFactory()</div>
<div> .getBuilder(Envelope.DEFAULT_ELEMENT_NAME)</div><div> .buildObject(soapEnvelope);</div><div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>Header header1 = envelope.getHeader(); // null</div>
<div><span class="Apple-tab-span" style="white-space: pre; ">                </span>Body body = envelope.getBody(); // null</div></div><div><br></div><div>but header1 and body are null.</div><div><br></div><div><div><span class="Apple-tab-span" style="white-space: pre; ">                </span>Header header = (Header) Configuration.getBuilderFactory()</div>
<div> .getBuilder(Header.DEFAULT_ELEMENT_NAME)</div><div> .buildObject(soapHeader);</div><div><br></div>This one is at least != null but header has no methods for adding children, such as the security element shown below.</div>
<div><br></div><div>Tried getOrderedChildren(), but that's not modifiable. The commented-out text is what I was trying before.</div><div><div><br></div><div><span class="Apple-tab-span" style="white-space: pre; ">                        </span>List<XMLObject> hdrChildren = header.getOrderedChildren(); // can't use this; unmodifiable list</div>
<div><span class="Apple-tab-span" style="white-space:pre">                        </span>Security security = newSecurity();</div><div><span class="Apple-tab-span" style="white-space:pre">                        </span>hdrChildren.add(security);</div><div>//<span class="Apple-tab-span" style="white-space:pre">                        </span>security.setParent(soapHeader);</div>
<div>//<span class="Apple-tab-span" style="white-space:pre">                        </span>SecurityMarshaller secM = new SecurityMarshaller();</div><div>//<span class="Apple-tab-span" style="white-space:pre">                        </span>Element securityElmt = secM.marshall(security, document);</div>
<div>//<span class="Apple-tab-span" style="white-space:pre">                        </span>soapHeader.appendChild(securityElmt);</div></div><div><br></div><div>I'm sure its something very simple (software problems always are) but I'm just not getting past first base with this. </div>
</font></div>