Simulating LOB Application using WCF LoopBack Adapter Binding in BizTalk

I am a big fan of WCF LoopBack Adapter Binding in BizTalk and would like to share a trick which I often use to simulate LOB Application while I am developing a new orchestration.

Many times when we are developing an orchestration which need to interacts with an LOB Application (using solicit response Send Ports such as SQL, SAP, etc), we are often stuck to complete the unit testing since there can be limitations to integrate with LOB App on our dev boxes or may be LOB App is not ready to start integration testing. Due to this we may sometimes not able to complete the dev of orchestration or even if have done, we might not be able to properly unit test it.

In these situations, I use WCF LoopBack Adapter Binding using which I can simulate any response expected out of solicit response Send Port of the LOB App.

I am not going into details on how to develop the WCF LooBack Adapter binding and how to install and configure it for your BizTalk box. For more details on this binding, you can refer to this excellent post http://synthesisconsulting.net/blog/2012/5/17/biztalk-wcf-loopback-binding.html

For example, lets say that I need to call a SQL Stored Procedure from the Orchestration and will be using a WCF-SQL Adapter on a solicit response Send Port. I do have the request and response schema’s and have completed the orchestration development using that but wanted to test my orchestration for different scenarios once it receive the response back from the SQL.

For this to simulate, I create a new Send Port using LoopBack Adapter Binding as shown below and will be binding this port to the Orchestration for testing.

1. Create the Send Port using LoopBack Adapter binding. Make sure to select the XMLReceive pipeline for the Receive Pipeline.LoopBackSendPortConfig1

2. Set the URI and Action Header as required for the LoopBack Adapter binding.

LoopBackSendPortConfig2

3. Keep the binding Configuration to Default.

LoopBackSendPortConfig3

4. This is the most important step where we define what response message will be sent back by this Loopback Adapter, Come to Messages Tab and set the Outbound WCF Message Body as Template. Now specify the response message which is expected from the LOB App (here SQL) and which matches the response schema as well.

For my example, lets say the response expected looks like below.

<ns0:SQLResponse xmlns:ns0=”mycompany”>
<ns0:Response>
<ns0:Status>0</ns0:Status>
<ns0:Data>
<ns0:Property>test</ns0:Property>
</ns0:Data>
<bts-msg-body xmlns=”http://www.microsoft.com/schemas/bts2007&#8243; encoding=”xml”/>
</ns0:Response>
</ns0:SQLResponse>

Make sure that you include the bts-msg-body (which represents the request message) somewhere inside it as shown above. This mostly will be ignored by the XMLReceive pipeline at the Send Port and the Orchestration as we are not doing any validation on the response message.

LoopBackSendPortConfig4

Now you are good to test the orchestration with this Send Port simulating the SQL LOB App. We can keep changing the response date for simulating different scenarios and test the orchestration flow. For above example, I can change the Status to 1, 2, etc as per my scenario and test the behavior of orchestration.

At times, this little trick comes very handy and as a developer, it gives me confidence while developing BizTalk solutions in a early stage.

3 thoughts on “Simulating LOB Application using WCF LoopBack Adapter Binding in BizTalk

  1. You may want to checkout a customization I made on top of the loop back adapter whereby you can capture the messages being sent out into the file system and take messages from the response-inbound as response. If you place multiple response files in the response-inbound folder, an instance of the port will iterate thru each file for multiple send-receive operations, useful for testing loops inside your ODX- > https://github.com/miguelcudaihl/Two-Way-Send-Receive-File-Adapter-for-BizTalk

  2. Hi, I know this is an old post but I am trying to find the WCF LoopBack Adapter binding.
    The link in your post is no longer available.
    I tried to google it but I am unable to find it. Could you point me to a place where I can download it from?
    I am not looking for the LoopBack Adapter but I am looking for the binding to use in a WCF-Custom send port.

Leave a comment