EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Create SOAP message from existing nonSOAP XML

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#37031
Posted: 06/20/2016 09:24:55
by Karel Benák (Standard support level)
Joined: 03/16/2011
Posts: 12

Hello,
how can I generate SOAP message from existing non SOAP message? For example:
Code
<Trzba><Hlavicka dat_odesl="2016-09-19T19:06:37+01:00" ... /><KontrolniKody><pkp cipher="RSA2048" digest="SHA256" encoding="base64">...</pkp><bkp digest="SHA1" encoding="base16">...</bkp></KontrolniKody></Trzba>

is TElDOMDocument XML message and I need sign and send throw SOAP. How I sign SOAP message message is not currently relevant.

Unfortunately I was unable to find a suitable piece of code in your examples, or I misunderstood how to generate a SOAP message from a non-SOAP XML documents.
May I use TElXMLSOAPEnvelope.CreateBody() and TElXMLSOAPEnvelope.LoadXML(existingXml)? Or do I need to create an entire XML document again?

Thank you for answer
#37032
Posted: 06/20/2016 12:55:20
by Dmytro Bogatskyy (EldoS Corp.)

Thank you for contacting us,

Quote
Unfortunately I was unable to find a suitable piece of code in your examples, or I misunderstood how to generate a SOAP message from a non-SOAP XML documents.
May I use TElXMLSOAPEnvelope.CreateBody() and TElXMLSOAPEnvelope.LoadXML(existingXml)? Or do I need to create an entire XML document again?

So, you need to place the content of xml document into the SOAP Body element of newly created SOAP message, right?
In this case, you need to append the contents of xml document to the Body element. Please, try to use the following code:
Code
        void CreateSOAPMessageFromFile(string inXMLFilename, string outSOAPFilename)
        {
            TElXMLDOMDocument XMLDocument = new TElXMLDOMDocument();
            TElXMLSOAPMessage SOAPMessage = new TElXMLSOAPMessage(null);
            try
            {
                SOAPMessage.CreateEnvelope(XMLDocument, SBXMLSOAPCore.Unit.SOAP_v1_1, "SOAP-ENV");
                if (SOAPMessage.Envelope.Header == null)
                    SOAPMessage.Envelope.CreateHeader();

                if (SOAPMessage.Envelope.Body == null)
                    SOAPMessage.Envelope.CreateBody();

                using (TElXMLDOMDocument InXMLDocument = new TElXMLDOMDocument())
                {
                    InXMLDocument.LoadFromFile(inXMLFilename);
                    SOAPMessage.Envelope.Body.XMLElement.AppendChild(InXMLDocument.DocumentElement.CloneNode(true, XMLDocument));
                }

                XMLDocument.SaveToFile(outSOAPFilename);
            }
            finally
            {
                SOAPMessage.Dispose();
                XMLDocument.Dispose();
            }
        }


P.S. You can find SOAP message how-to articles here: https://www.eldos.com/documentation/sb...ssage.html
#37033
Posted: 06/20/2016 18:48:04
by Karel Benák (Standard support level)
Joined: 03/16/2011
Posts: 12

Thank you

exactly this piece of code is what I was looking for!
Code
SOAPMessage.Envelope.Body.XMLElement.AppendChild(InXMLDocument.DocumentElement.CloneNode(true, XMLDocument));

Reply

Statistics

Topic viewed 591 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!