using System.Xml.Linq; using dk.nsi.seal.Model.Constants; namespace dk.nsi.seal.Model.DomBuilders { public abstract class AbstractSoapBuilder : AbstractDomBuilder { /// /// Method called by .
/// Override this method to control the creation of the root Element.
/// The default implementation adds soapenv:Envelope element and invokes the {@link #addRootAttributes(org.w3c.dom.Element)} method. ///
/// protected override XElement CreateRoot() { return XmlUtil.CreateElement(SoapTags.Envelope); } protected override void AppendToRoot(XElement root) { // HACK: Needs to write body first, or the assertion validation will fail after signing the message in the header. // hash values for assertion will change if header is not last ?!? AppendBody(root); AppendHeader(root); } protected abstract void AddBodyContent(XElement body); /// ///Method called by .
/// Use this method to add the actual contens to the header element. ///
/// THe content is added to this header protected abstract void AddHeaderContent(XElement header); /// /// Method called by .
/// Override this method to control the creation of the body Element.
/// The default implementation adds soapenv:Body element. ///
/// Envelope the body is added to protected void AppendBody(XElement envelope) { var body = XmlUtil.CreateElement(SoapTags.Body); body.Add(new XAttribute(NameSpaces.xwsu + "Id", "body")); envelope.Add(body); AddBodyContent(body); } /** * Method called by {@link #createDocument()}.
* Override this method to control the creation of the header Element.
* The default implementation adds soapenv:Header element. * * @param doc * The Document container instance. * @param envelope * The root Element instance. */ /// /// Method called by .
/// Override this method to control the creation of the headerElement.
/// The default implementation adds soapenv:Header element. ///
/// Envelope the body is added to protected void AppendHeader(XElement envelope) { var header = XmlUtil.CreateElement(SoapTags.Header); envelope.Add(header); AddHeaderContent(header); } } }