No, I’m not raising money for a charity — I’m doing work with files and binary data via .Net web services. You probably don’t hear that in the same sentence very often! Several months ago, DIME (Direct Internet Message Encapsulation) was the latest buzz-word in transmitting files over http for web services; web service enhancements (WS-E) relied on DIME for attachments; there was a flurry of articles (like this one) on how DIME was THE way to include documents in your web service communications. Recently, however, luminaries such as Don Box and Gudge have reported DIME is dead. They offer an alternative: Proposed Infoset Addendum to SOAP Messages with Attachments (or the catchy acronym: PASWA). But as far as I know, this is an abstract alternative. There isn’t a concrete implementation of PASWA or WS-E version that incorporates PASWA.
What’s a guy with a laptop and a customer with a large document-centric web service requirement to do? I don’t want to use DIME if it’s current implementation is not likely to continue, but DIME via WS-E (WS-E Attachments as it’s known) is considerably faster than xml encoding all the bytes in a file. If you’re curious, WS-E Attachment is well-documented in articles such as this one by Mike Gunerloy; the “old fashion“ way is to move your attachment into a byte array and shuttle it like any normal web service parameter, like this from the client side:
FileStream fsm = File.Open( “File.doc”, FileMode.Open, FileAccess.Read );
byte byteArray = new byte[ fsm.Length ];
fsm.Read( byteArray, 0, int.Parse( fsm.Length.ToString() );
//invoke webservice, passing byteArray as a parameter . . .
And this from the webservice side:
MemoryStream mem = new MemoryStream( byteArrayParam ) );
FileStream fsm = new FileStream( “New File Name”, FileMode.Create );
mem.WriteTo( fsm ); mem.Close(); fsm.Close();
Simple and sophisticated, but not quick. So, the 10 cent question is do I stick with the slower option or go with the “Dead“ DIME solution? Is there another path? I’m sure if I’m patient enough, I could wait for a new release of some package and be up and running with PASWA; if I was more enterprising and had more time, I might take a stab at implementing PASWA as an extension to what I’ve got right now — sounds fun, but not a viable option.
I guess I avoid DIME (afraid that future web service / SOAP stacks won’t implement it) and go with the byte array approach? Am I missing something?