Options

XML File Signature

weneedweneed Member Posts: 81
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?

Best Answer

  • Options
    ftorneroftornero Member Posts: 522
    Answer ✓
    Hello @weneed,

    In the UTF-8 BOM case you would need to remove this three chars (ef bb bf).

    Regards.

Answers

  • Options
    ftorneroftornero Member Posts: 522
    Hello @weneed,

    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.
  • Options
    vaprogvaprog Member Posts: 1,118
    That external web service does not adhere to the xml specification. See here: https://w3.org/TR/REC-xml/#sec-guessing

    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.
  • Options
    weneedweneed Member Posts: 81
    I' using XMLport with Format property set to XML

  • Options
    ftorneroftornero Member Posts: 522
    Answer ✓
    Hello @weneed,

    In the UTF-8 BOM case you would need to remove this three chars (ef bb bf).

    Regards.
  • Options
    weneedweneed Member Posts: 81
    Thanks I hadn't noticed that
Sign In or Register to comment.