I need to send an XML file created with XML Port object to an external web service. Webservice verify file signature to check real file format.
It expects to receive an xml file with the first 5 bytes set like this:
0x3C, 0x3F, 0x78, 0x6D, 0x6C, 0x20
but file created from BC contain file text signature: ef bb bf or ff fe 3c 20 3f 20
This is wikipedia
link
So why BC does it create xml files without the correct signature?
Answers
ef bb bf
is that the file is UTF-8 BOM https://en.wikipedia.org/wiki/Byte_order_mark
And
ff fe
is that the file is UTF-16.
How do you create the XML file ??
Regards.
Neither does Microsoft, as it is recommended to not use a BOM for XML.
When I last checked, I was unable to write an xml file without BOM using an Unicode encoding and tools available in Dynamics NAV / BC.
You will have to post-process your file (or stream) in order to remove the BOM.
In the UTF-8 BOM case you would need to remove this three chars (ef bb bf).
Regards.