2

I'm trying to post a message on a MSMQ using WCF with a MsmqIntegrationbinding. Sending works but when I look at the message that has been sent to the queue. The encoding is incorrect.

Is it possible to change the message encoding to UTF-16? I already tried to solve this using a custom binding. This didn't solve my issue. I pasted the custom binding that I used below.

<binding name="CustomMsmqIntegrationBinding">   
   <textMessageEncoding messageVersion="None" writeEncoding="utf-16" />
   <msmqIntegration exactlyOnce="true">
      <msmqTransportSecurity msmqAuthenticationMode="None" msmqProtectionLevel="None" />
   </msmqIntegration>
</binding>
Casper
  • 135
  • 1
  • 12

1 Answers1

2

The question is, do you have a reason that forces you to exactly use UTF-16?

Have you seen this link in the MSDN forums: "How to make UTF-16 as default encoding for WCF Data Services."?

As a possible solution it suggests:

The client can send Accept-Charset: utf-16 header in the request and the server will respond using UTF-16.

And the accepted post says:

[...] UTF-8 supports the exact same set of characters as UTF-16. So unless you have a client which can only consume UTF-16 and not UTF-8 there should be no reason to use UTF-16 over UTF-8. To the contrary in fact, UTF-16 payloads are almost 2 times larger than UTF-8.

Jens H
  • 4,590
  • 2
  • 25
  • 35
  • The problem I have is that the application that is consuming the Queue won't pick up the messages. I thought this was because of the encoding of the message. The problem can lay somewhere else though. The message that is being sent by the msmqIntegrationBinding is a binary xml file. The consuming application probably only accepts plain text. Do you know if it's possible to send the message as plain text to the Queue? – Casper Mar 26 '12 at 16:41
  • @Casper: The binary binding is default, so you want to try a custom binding like this: ` ` But I am no expert in this. :( – Jens H Mar 26 '12 at 16:52