public void CreateSoapMessage(Action <object> setSoapBody, object fields) { XmlDoc = new XmlDocument(); var xmlDeclaration = XmlDoc.CreateXmlDeclaration("1.0", "utf-8", null); EnvelopeNode = XmlDoc.CreateElement(SOAPENV, nameof(SoapMessageFields.Envelope), SOAPENV_NS); var headerNode = XmlDoc.CreateElement(SOAPENV, nameof(SoapMessageFields.Header), SOAPENV_NS); BodyNode = XmlDoc.CreateElement(SOAPENV, nameof(SoapMessageFields.Body), SOAPENV_NS); setSoapBody(fields); XmlDoc.AppendChild(EnvelopeNode); EnvelopeNode.AppendChild(headerNode); EnvelopeNode.AppendChild(BodyNode); }
//There may be additional namespaces required for the soap message, this method handles dynamically adding them public void AddEnvelopeNodeNamespace(string prefix, string ns) => EnvelopeNode.SetAttribute($"xmlns:{prefix}", ns);