user3726933
user3726933

Reputation: 359

Storing WCF Soap request as XML Type in SQL Server 2008 R2

I have a legal requirement to store the entire SOAP request to my service in a database. I have SQL Server 2008 R2. And I recently learnt about the XML datatype in SQL Server. My requirement is to store the request xml and expose the same in the get method of the service. This data is not 'transactional' as in nobody can make updates to this request. So is the XML type a good candidate for this? And I want to be able to tie a schema with this.

Request Id int
Request XML

Upvotes: 0

Views: 216

Answers (1)

marc_s
marc_s

Reputation: 755217

As long as these SOAP requests are indeed well-formed XML - sure, you can use the XML datatype for this - that's what it's been introduced for in SQL Server 2005 !

One point to be aware of: the XML is not stored as is as a text representation - it is tokenized and stored in an optimized fashion. So when you ask for the XML back from SQL Server, you'll get an XML representation that is semantically correct - but it might not be exactly the same as you stored into the XML column. SQL Server can e.g. replace an explicit opening and closing tag (<SomeNode></SomeNode>) with an auto-closing tag (<SomeNode />) or do other optimizations. Just something to know when you're using the XML datatype in an auditing capacity as you seem to intend it for.

Upvotes: 1

Related Questions