by Mark Shiffer
3. August 2009 21:16
I recently came across an odd issue and figured I would detail it here in case it will help anyone else down the line. I have a WCF service using wsHttp binding that when called returns a custom data contract that includes a .NET DataSet as one of its data member properties. This worked great for 99% of the calls that I made to the service, but I came across one call that took 40 minutes to return! The data being returned amounted to 4MB, which is large, but does not warrant the time it was taking. Under WSE, this same contract returned in 4 seconds.
It is not suggested to return .NET classes as part of a service contract as it hampers interoperability. However, when you need to shove a great deal of relational data from the service down to the client, you either use a DataSet and its built-in XML serializer or come up with your own serialization and deserialization schemes to accomplish the same thing. I opted for the former. The XML representation might not be great, but it works and it can be interpreted by non-.NET clients if need be.
So my question was, why does this particular contract take so long to return? Is it the size, the DataSet serialization/deserialization, or something else all together. When I started investigating, one of the first things that I noticed was that message tracing showed that the contract took 3 seconds to execute on the server. Fiddler showed me that the response message was making it back to the client in the expected time. So, the 40 minutes was being taken up almost entirely on the client side, presumably while deserializing the DataSet. After a great deal of messing around with other encoding schemes I found that I could send large responses in binary form and as a Base-64 string without issue.
The kicker was when I found that I could even send a large DataSet without issue. Wait a second, that is what was causing the original issue wasn’t it? Turns out, the contract in question returned a one row, one column result where the value was a very large XML text blob. After further testing, I found that WCF and wsHttp performance degrades exponentially when a DataSet that contains an XML string column in it grows.
Lesson learned. I have the ability to manipulate this particular call to return a more formal response without the need for the XML blob. So that will solve my issue for now.
20ea7997-429e-4138-bab4-fde927ab813d|0|.0
Tags:
Issues