Consuming the Adapter from outside BizTalk Server

2 min read

In addition to infrastructure-related updates such as the aforementioned platform modernization, Windows Server 2008 Hyper-V virtualization support, and additional options for fail over clustering, BizTalk Server also includes new core functionality. You will find better EDI and AS2 capabilities for B2B situations and a new platform for mobile development of RFID solutions.

One of the benefits of the new WCF SQL Server Adapter that I mentioned earlier was the capability to use this adapter outside of a BizTalk Server solution. Let’s take a brief look at three options for using this adapter by itself and without BizTalk as a client or service.

Called directly via WCF service reference

If your service resides on a machine where the WCF SQL Server Adapter (and thus, the sqlBinding) is installed, then you may actually add a reference directly to the adapter endpoint.

I have a command-line application, which serves as my service client. If we right-click this application, and have the WCF LOB Adapter SDK installed, then Add Adapter Service Reference appears as an option.

Choosing this option opens our now-beloved wizard for browsing adapter metadata. As before, we add the necessary connection string details and browse the BatchMaster table and opt for the Select operation.

Unlike the version of this wizard that opens for BizTalk Server projects, notice the Advanced options button at the bottom. This button opens a property window that lets us select a variety of options such as asynchronous messaging support and suppression of an accompanying configuration file.

After the wizard is closed, we end up with a new endpoint and binding in our existing configuration file, and a .NET class containing the data and service contracts necessary to consume the service.

We should now call this service as if we were calling any typical WCF service. Because the auto-generated namespace for the data type definition is a bit long, I first added an alias to that namespace. Next, I have a routine, which builds up the query message, executes the service, and prints a subset of the response.

using DirectReference = schemas.microsoft.com.Sql._2008._05.Types.
Tables.dbo;
 …
private static void CallReferencedSqlAdapterService()
{
Console.WriteLine("Calling referenced adapter service");
TableOp_dbo_BatchMasterClient client = new TableOp_dbo_
BatchMasterClient("SqlAdapterBinding_TableOp_dbo_BatchMaster");
try
{
string columnString = "*";
string queryString = "WHERE BatchID = 1";
DirectReference.BatchMaster[] batchResult =
client.Select(columnString, queryString);
Console.WriteLine("Batch results ...");
Console.WriteLine("Batch ID: " + batchResult[0].BatchID.ToString());
Console.WriteLine("Product: " + batchResult[0].ProductName);
Console.WriteLine("Manufacturing Stage: " + batchResult[0].ManufStage);
client.Close();
Console.ReadLine();
}
catch (System.ServiceModel.CommunicationException){client.Abort(); }
catch (System.TimeoutException) { client.Abort(); }
catch (System.Exception) { client.Abort(); throw; }
}

Once this quick block of code is executed, I can confirm that my database is accessed and my expected result set returned.

Packt

Share
Published by
Packt

Recent Posts

Top life hacks for prepping for your IT certification exam

I remember deciding to pursue my first IT certification, the CompTIA A+. I had signed…

3 years ago

Learn Transformers for Natural Language Processing with Denis Rothman

Key takeaways The transformer architecture has proved to be revolutionary in outperforming the classical RNN…

3 years ago

Learning Essential Linux Commands for Navigating the Shell Effectively

Once we learn how to deploy an Ubuntu server, how to manage users, and how…

3 years ago

Clean Coding in Python with Mariano Anaya

Key-takeaways:   Clean code isn’t just a nice thing to have or a luxury in software projects; it's a necessity. If we…

3 years ago

Exploring Forms in Angular – types, benefits and differences   

While developing a web application, or setting dynamic pages and meta tags we need to deal with…

3 years ago

Gain Practical Expertise with the Latest Edition of Software Architecture with C# 9 and .NET 5

Software architecture is one of the most discussed topics in the software industry today, and…

3 years ago