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.

Consuming the Adapter from outside BizTalk Server

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.

Consuming the Adapter from outside BizTalk Server

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.

Consuming the Adapter from outside BizTalk Server

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.

Consuming the Adapter from outside BizTalk Server

LEAVE A REPLY

Please enter your comment!
Please enter your name here