first_page

Redesigning My XML-over-HTTP Data Access Layer for LINQ

To people firmly entrenched in the world of SOAP Web Services, a Java-centric, IBM-style SOA architecture—one big-ass server for multi-million requests per minute, my data access layer is utterly appalling—humorous even. I guess I’m lucky because I am unable to understand just how appalling it is. I was even crazy enough to write about (pieces of it) on my green-colored company web site—“Songhay.NET: An Overview of the Songhay Data Namespace.”

One of the craziest bits in the Songhay Data Namespace is a strategy in the form of ICommandHandler. This ‘Command Handler’ is frighteningly biased toward XML over HTTP scenarios. Using XML over HTTP (instead of SOAP XML) is like saying “I’m unemployed” to the Java Posse (just kidding guys). It’s like saying “I am complete idiot” to the architects of WS-Security (not really kidding here). So, now that you know what you are dealing with, here is the existing scenario (from the cloud into the data layer):

  • A strange, wild XML message arrives at the façade using the ICommandHandler strategy. The message could be a string, a navigable document (or any other type for that matter) stored in the DataCommandInput.PostData property.
  • The incoming post data is validated. My preference is to make a few XPath assertions against a navigable document.
  • The validated data might be parsed into a parameter array that will be used with a parameterized SQL string. (My Songhay.Data.Common namespace is designed to handle this.)Now more crazy stuff: before LINQ was released I wrote SQL queries in text files and stored them as resources to be compiled in my data access assembly. This must be more stupidity for those who are comfortable with using stored procedures. But those people are likely writing a set of procedures for one big-ass system—their database is more likely to be huge and unique. In my little world, my databases are numerous, “small” (less than one million rows) and they have the same schema. So, for the sake of maintainability (over performance), it is better (for me) to have parameterized procedures compiled in the code so it can be reused for different databases of the same schema.

What LINQ to XML does for me is eliminate the need to write SQL statements to be compiled in an assembly. This is actually crazy. Implied here is something very daring: LINQ can replace all of the functionality I need in Transact SQL for SQL 2005—even the great, new XML functionality in SQL Server 2005. Here are some examples of this great functionality (from my notes):

rasx()