OK, so this week I found out that that there currently is no support the the Jet database provider on the x64 platform. That didn't change the fact that I was determined to do it (or create the illusion of it). I had to create a user-approachable report generator which exported the data into Excel and sent it on to the user all via a web interface. I also didn't want to use the XML version of Excel spreadsheets (it surprises me how many times people think I'm talking about Excel 12 when I say that. You can do XML-based sheets in old Excel versions too!) So I wanted this done via ADO.NET and the Jet provider creating a "real" xls file. Obviously what I wanted to do isn't even work with the framework, but...doing it on x64 is.
The solution? Simple, WSE3 provides you with the ability to use SOAP Message Transmission Optimization Mechanism (MTOM) very seamlessly. MTOM is a new W3C recommendation used to optimize messaging scenarios that involve transmitting binary data. Technical gibberish aside, MTOM is just AWESOME. Using WSE3/MTOM, all I had to do was create a WSE3 service on a different server which created the XLS binary data and returned to back to the caller which then sent it on to the client.
Want specifics? MSDN has a document which provides you with the hands-on training you sufficient to propel you into WSE3 services: WSE3 Hands-on Lab: Messaging. MTOM is the third lab, but basically all you do is enable WSE3 (and MTOM) on the client and server, set the server up to return a byte array to the caller, call the server, and stream that byte array into a file. In my case I then sent it out to the user...
Here's my code for sending the Excel worksheet out to the user...
Response.Buffer = true; Response.Clear( ); Response.ClearContent( ); Response.ClearHeaders( ); Response.AddHeader("Content-Disposition", "attachment; filename=" + "AutoGeneratedReport.xls"); Response.AddHeader("Content-Length", file.Length.ToString( )); Response.ContentType = "application/vnd.ms-excel"; Response.WriteFile(fullpath); Response.Flush( );
I'll have to beef up on WSE3 a bit for a future SOA lecture in my WinFX/.NET course.