So, I’m writing this lovely little web service, and I have a method called “LoadView”, which (ok, don’t give me a hard time) returns a DataTable of a view. Works fantastic. OK, I had to tweak the “maxReceivedMessageSize” because like, duh, I want more than 64K of data, but no biggy because the exception was oh so kind to tell me that I ought to do that.
Same with a call to GetSchema, which simply returns an XML string of the DB schema. Got a nice exception that told me I had to increase maxStringContentLength in the readerQuotas because, duh, I have XML elements that are greater than 8K of content. Doesn’t everybody?
So, these two calls are working great, and I’m off to the last method I want to implement, “ExecuteQuery”. Yeah, on the server side it verifies that the SQL statement begins with “select” or “with”, and there’s parameterization checks so I have some effort to prevent SQL injection attacks, but I’m not really concerned because this is for an Intranet solution, so I can pretty much rely on the fact that the people are who connecting to the web service are in fact, moral, ethical, upstanding denizens of the aerospace industry.
But I digress.
So, I get this lovely exception (recreated just for you, dear reader, after having fixed the problem):
An error occurred while receiving the HTTP response to http://%5Bsnip%5D. This could be due to the service endpoint binding not using the HTTP protocol. This could also be due to an HTTP request context being aborted by the server (possibly due to the service shutting down). See server logs for more details.”}
WTF? I’m returning a DataTable, just like I am in the LoadView call, which works perfectly. I have absolutely no freaking clue as to what is going on. I notice that my interfaces have the ExecuteQuery and GetSchema methods swapped in the client and the server. Nope, that’s not it. I try returning a simple empty data table. You know, like “return new DataTable();” and I still get the same error! How can that be???
So, suddenly an angel thwaks me on the side of the head. “Hey you depraved lowly human being with your limited life span, you want to spend the next 8 hours of your short little puny life figuring this out, or do you want some divine inspiration? Don’t answer that, that was a rhetorical question. OK, remember that time a few years ago when you tried serializing a DataTable and the serializer crapped out on you because you didn’t give the DataTable a name? HINT!!!”
And there was much rejoicing, and angels partied down.