By Robert Bulugea
I needed to send orders in XML format over webservice calls and I soon realized that although there were some resources on how you can do that with JSON text structures, there weren’t many containing XML structures.
Let’s have a look how I achieved this in a few simple steps below:
In my context I am logging the XML message that I am sending into a Blob field of an integration log table.
Step1 – I created the relevant fields here:
Step 2 – I also created a very simple XMLPort, feel free to create one suitable to your needs.
Step 3 – Now what we need is to have two functions that would:
3.1 Stream the contents of a message into our blob field, which is exactly what the function below does
3.2 Stream the contents of our blob field into a text variable, exemplified in the ReadXML2Text procedure below
Step4 – Sending the XML message to our destination with Http Post.
We then send the xml text variable to a codeunit were we are using the HTTPContent.writefrom function
To view download the source code please click here (you can make use of it as it is, just include your Launch file)
MSDYN365BC Webservice HTTP Post with XMLTweet