Monthly Archives: February 2006

The work-at-home donut disadvantage

I think this post is just for my friend Dave who works at home and has more than his fair share of blog posts about donuts.

Rich bought a box of little chocolate covered donuts last night. I begged and pleaded with him to let me have some. He’s a good husband though and tries to help me when it comes to succumbing to my dreadful addiction to chocolate. Especially as he’s the one who has to hear me whine about the way my jeans fit (or don’t, as the case may be).

His first response was “donuts are for people who go to work”. That did not go over well since I happen to work about 12 or more hours a day. So then he tried “donuts are for people who leave the house to go to work.” Boo hiss.

After he “left the house to go to work” this morning I came downstairs knowing that surely, because he loves me so very very much, he had left me a few of these little tasty treats. But they were nowhere to be found. He told me later that he had departed with the fully sealed box of donuts this morning. I had to make due with oatmeal, since the closest possible source is a 25 minute round trip drive. So here it is, nearly lunchtime, and I’m still thinking about those damned donuts!



Don’t Forget: www.acehaid.org

How to type WEB SERVICES with proper casing

Seems pretty inane, but this is the kind of stuff one has to worry about when writing articles. Although sometimes I can leave that to the great tech editors I get to work with like Melanie Spiller. I have gotten very good at properly casing things like SqlNotification and DataSet. But [web services] was always an issue for me. So today I went onto the W3C site and found the following on this page:

“The World Wide Web is more and more used for application to application communication. The programmatic interfaces made available are referred to as Web services.”

Okay, so I’m sticking with capital W and all lower case for the rest.

Don’t Forget: www.acehaid.org

Boosting Windows Forms App Performance – yay!!!

I can barely contain my excitement over this article, “Practical Tips for Boosting the Performance of Windows Forms Apps” by Milena Salman in MSDN Mag (March 06). I read most of it this morning over breakfast and came down to my office with the sole intent of opening up the windows forms app I am getting ready to re-deploy in it’s shiny new .NET 2.0 makeover and finding any place that I can apply all of the awesome advice Milena dishes out in this article.

Of course, now it’s 2:00 and if I can just turn off Outlook, I.M. and the phone, I might actually get started on this.

Don’t Forget: www.acehaid.org

How I use XCeed streaming compression component to return web service data

I have mentioned my use of the XCeed streaming compression for returning data from web services a number of times in this blog. Here is a post when I first discovered that it reduced a 2.9 minute download of  4 MB to 12 seconds! I have since mentioned it a few times but never showed exactly how it is coded. Last night Rod Paddock pinged me to find out if I thought that component would work for him and it turned out he had the exact same scenario as I have been using it for. Therefore I showed him my code and thought I would put it here as well.

The key to all of this is that the component compresses bytes, so whatever you are returning, you want to convert it to bytes first. I’m sure this may make some web service purists cringe, but is it any different than returning a binary attachment with MTOM – which is a W3C standard? (I’m open to further education on this, my purist friends!)

Anyway, back to stream compression.

Let’s say you have a .NET client to .NET service scenario and are writing both ends. (That is a setup to avoid any rotten tomatoes for using a dataset in this example 🙂 ).

On the web service end, I have a method that accepts the dataset, converts it to a byte array, compresses that into another byte array using XCeed QuickCompression class and then returns this compressed byte array.

Using ms As New System.IO.MemoryStream
 ds.WriteXml(ms)
 Dim bytearray(ms.Length) As Byte
 
bytearray = ms.GetBuffer
 
Dim CompressedBytes() As Byte
 
CompressedBytes = QuickCompression.Compress(bytearray, CompressionMethod.Deflated, CompressionLevel.Normal)
 
Return CompressedBytes
End Using 

On the client end, having called this web service operation, I decompress the received bytes into a new byte array, then read that byte array into a new DataSet. Et Voila!

Dim ds As New DataSet
Dim compressedBytes() As Byte = WSProxy.GetDataSetasCompressedBytes
Dim byteArray() As Byte
= QuickCompression.Decompress(compressedBytes)
Using ms As New
MemoryStream
  ms.Write(byteArray, 0, byteArray.Length)
  ms.Position = 0
 
ds.ReadXml(ms)
End Using

I remember when I was first looking for a means of doing this and reading about this component, it wasn’t obvious how to do this in a web service, so I had a pointer from someone in tech support as to how to accomplish this.

I have used this combined with WSE 2.0 and now with WSE 3.0 to protect this data in addition to compressing it. If you have really humongous files, you can combine compression with MTOM in WSE 3.0 as well. I’ll have to check this out with WCF at some point.

Don’t Forget: www.acehaid.org

WCF Article Series by the pros coming up in CoDe Magazine

I’m looking at Rod Paddock’s editorial in the current CoDe Mag issue. This is the future tehcnologies issue wiht articles on WPF, LinQ and Ajax. In the editorial he says that there is going to be a 6 article series on WCF starting with the next issue. I’m really looking forward to this. Especially considering who is going to be writing some of these: Michele Leroux Bustamante, Juval Lowy, Christian Weyer.

Don’t Forget: www.acehaid.org