.NET SoapMessage How can I disable the UTF-8 BOM?

I’ve a small project where I have to get some data from an external Java SOAP Service.

The Java Service rejects all SOAP requests, if there’s a BOM before the opening XML tag.
I’ve tried all SoapModes and Serialization Options of the ROSDK SoapMessage, but none of this settings has disabled the BOM.

The Server side is externally managed. What I’ve to do to suppress the BOM at the client side?

Hello Jens.

Please consider to use the next way: on the client side implement channel event BeforeSendStream, check first element on 0xEF and delete it if it is necessary as follows:

  private void clientChannel_BeforeSendStream(object sender, StreamEventArgs e)
    {
        Byte[] buffer = RemObjects.SDK.Helpers.StreamHelpers.StreamToBuffer(e.Stream as System.IO.Stream);
        Byte[] newBuffer = null;

        if (buffer[0] == 0xEF)
        {
            newBuffer = new Byte[buffer.Length - 1];
            Buffer.BlockCopy(buffer, 1, newBuffer, 0, buffer.Length-1);
            e.Stream = new MemoryStream(newBuffer);
        }
    }

Thanks

Great. This code is much cleaner than my workaround. Thank you.

Could you think about adding a “Disable sending UTF-8 BOM” property on each channel type?
Or a bit more generally - two property goups “outbound stream encoding options” and “inbound stream encoding options”?

Hello Jens.

Glad to hear that this workaround is fine for you. Thank you for suggestions. We will consider about adding BOM option functionality.

Thanks.