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:
![Table solel "Integration Log"
Dataclassification = CustcærContent;
Caption — •Integration Log';
Robert eulugea. 3 days ago I I author (Robert Bulugea)
fields
1 reference
field(le; "Entry No."; Integer)
Au t OlnC
field(2e; "ML File BLæ"; Blob)
DataCIa55ification — CustomerContent;
I reteremce
Field (30; Code [20])
DataCIassification CustomerContent;](https://abcdrive.files.wordpress.com/2020/06/image.png?w=526)
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 download the source code please click here (you can make use of it as it is, just include your Launch file)
For other useful blogs and content please visit Acumen’s insights page here
MSDYN365BC Webservice HTTP Post with XML
Tweet