The scenarios is as follows:
Picture 1. Diagram of the scenario.
In the following steps will provide a demonstration how to configure receive and send port with the WCF-MSMQ binding (adapter). The first step after deploying a BizTalk solution is to configure send, receive ports and/or the orchestration(s), and/or any other type of configuration. After creating a receive port you need to add a receive location.
Picture 2. Configure the receive location with WCF-MSMQ Binding (Adapter).
Picture 3. Configure MSMQ Properties.
Picture 4. Specify the receive pipeline.
The Send Port configuration with MSMQ binding (adapter) is as follows.
Picture 5. Specify the MSMQ Transport Properties Send Port.
Picture 6. Send Port with WCF-MSMQ Binding (Adapter).
Picture 7. XMLTransmit Pipeline Properties.
A windows form client application will load an XML message. By loading an external order message into the application it can be sent to MSMQ: private$\ExternalOrders
Picture 8. MSMQ Client loading External Order Message to be sent.
Once SendMessage is clicked the message will be send to the queue ExternalOrders.
Picture 9. MSMQ Client Sending Message to the Queue.
In BizTalk the message is picked up and send port subscribing on the message will pick it up and send it to queue InternalOrders.
Picture 10. Internal Order Queue containing an Internal Order message.
Once the GetMessage is clicked the message will be read from the queue InternalOrders.
Picture 11. MSMQ Client gets the message from the queue.
In case you preserve the Byte Order Mark (BOM) from a message send to the queue you fill face the following challenge. The message in queue will look like below.
Picture 12. BOM visible in message properties (Body).
If you pick the message with a service and/or client that has the following implementation than you will not notice any difference as the BOM will be ignored.
XmlDocument xmlDoc =
new
XmlDocument();
xmlDoc.Load(msgInternalOrder.BodyStream);
It is possible that the BOM could interfere with how you read the message.
In case you use the XMLFormatter to the instance of the Message than you might face an issue. The implementation to read the msessage from the queue could look like.
//Read the message from the queue
System.Messaging.Message msgInternalOrder = internalOrderQueue.Receive();
msgInternalOrder.Formatter =
XmlMessageFormatter(
String[] {
"System.String,mscorlib"
});
String message = (
string
) msgInternalOrder.Body;
And an error will occur.
Picture 13. MSMQ Client providing an error message.
Note: This error will occur regardless of the BOM!
The code belonging to this article can be found on MSDN Code Gallery: BizTalk Server 2013 R2 WCF-MSMQ Binding (Adapter)
Another important place to find an extensive amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.