EldoS | Feel safer!

Software components for data protection, secure storage and transfer

TElRESTClient and BOM

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
#34872
Posted: 10/22/2015 13:11:56
by Doug Summersgill (Standard support level)
Joined: 05/14/2015
Posts: 12

I'm having an inconsistency on a Windows CE 6 application (C# compactframework 2.0)

When I use the TELRESTClient to post a TElXMLDOMDocument I am sometimes getting failures from my host web service.

Upon debugging and inspecting the outgoing buffer in the OnSendData event I have determined that sometimes the BOM characters (0xEF,0xBB,0xBF) are being added between the headers and the xml declaration.

When these characters exist I get the errors from the web service. Admittedly I know very little about the standards involved, but I feel like the web service should be able to handle and even expect the BOM.

However, I don't control the web service and I'm wondering why the BOM isn't always in the send buffer.

Is there some way I can control whether or not these characters are added?

Thanks.


Doug
#34874
Posted: 10/22/2015 14:39:37
by Dmytro Bogatskyy (EldoS Corp.)

Thank you for contacting us.

Quote
However, I don't control the web service and I'm wondering why the BOM isn't always in the send buffer.

Do you use different charsets for the request or do you always use the default/utf-8 charset?
For unicode charset the BOM (byte order mark) characters are added by default. You can save xml document without BOM characters and send it using the following code:
Code
using SBXMLCharsets;

using (MemoryStream ms = new MemoryStream())
{
  using (TElXMLUTF8Codec Codec = new TElXMLUTF8Codec())
  {
    Codec.WriteBOM = false;
    XMLDocument.SaveToStream(ms, SBXMLDefs.Unit.xcmNone, Codec);
  }

  RESTClient.RequestParameters.ContentType = "application/xml";
  ResultCode = RESTClient.Post(URL, ms, false);
}
#34875
Posted: 10/22/2015 16:28:29
by Doug Summersgill (Standard support level)
Joined: 05/14/2015
Posts: 12

I wasn't setting the charset.

I can try saving like your example, but I'm still wondering why I get the inconsistent results.


Doug
#34878
Posted: 10/23/2015 02:55:02
by Eugene Mayevski (EldoS Corp.)

BOM bytes should not be present in the middle of the data. BOM is (by the standard) to be placed at the very beginning.

Some implementation might skip BOM, but most of them won't.

Now about your problem -- we can only guess why you get inconsistent result. I assume that is because you perform different operations or maybe send different data (some of which already includes BOM mark at the beginning).

If you want to find out, what causes BOM to appear, then I would ask you to provide the test case which would illustrate the problem. We would be able to run this test case and see what's going on inside and why BOM appearance is inconsistent.


Sincerely yours
Eugene Mayevski

Reply

Statistics

Topic viewed 3128 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!