Pulling Images from InfoPath Xml

Sunday, November 23, 2003 8:54:54 PM (Central Standard Time, UTC-06:00)
Working on my InfoPath RSS Poster thing (for the lack of a better name).  Now that I can easily post to my blog using InfoPath I wanted to start taking advantage of also including images in the posts.  Well, I thought it would be pretty straight forward.  I had discovered after doing some exploratory coding that InfoPath happened to be using a serialization technique that was consistent with the XmlSerializer class. 
 
I could serialize an image to xml (storing the image data in a byte array), then manually paste it into InfoPath from my serialization harness and it would render correctly. Well for about the next four hours I pulled out every thing I could think of to figure out exactly how they were serializing the byte array to Xml. I leveraged some research I had done for a serialization presentation and took advantage of a post that Douglas Purdy had blogged on XmlSerialization (it described how to find the *.cs files created during dynamic compilation). That's how I found that the XmlSerializer was calling ToByteArrayBase64. Then I spent some time digging around the System.Xml.Serialization.XmlSerializationReader class in Rotor code to figure out exactly how it read the string contained in the xml to a byte[]. I found the answer in Rotor's xmlserializationreader.cs, they were using Base64 encoding on the byte array. The "magic" code is found here.
 
Now with just a couple of lines of code, I can read the Base64 encoded string and persist it to file as an image. Getting closer now to having images in my posts…

Using InfoPath to post to my blog (cont.)…

Tuesday, November 18, 2003 5:08:32 PM (Central Standard Time, UTC-06:00)
Alright, so I have made my first post with InfoPath to my blog. Not only is it cool, it's now easier for me to compose posts offline due to the fact I can persist to the file system.  As I sat down last night to right another post… spawned by the use Borland Together, my requirements for the my InfoPath posting tool are growing.  I need the ability to insert pictures in my posts (so you can see the Borland Together UI).  In addition I need the ability to categorize the posts according to my current categories, so I am not forced to sort them after the post.
 
Looks like I will have to work on that a bit this week and see if I can't get a working model by the weekend.  When I am done I will share some of things I ran into…  I already have seen a couple of things I would like changed/added to InfoPath.
 
 

InfoPath as a RSS Smart Client

Monday, November 17, 2003 1:08:57 PM (Central Standard Time, UTC-06:00)
This all started when I wasn't quite satisfied with the tools I was using to publish to my blog. w.bloggar wasn't working correctly with dasBlog (or I didn't configure it properly) and I didn't want to take the time to debug and see what was going on in the BloggarAPI and dasBlog interaction. MailToWeblog worked fine as long as I didn't use the e-mail server at work, they would strip html out, so I would loose my formatting in the posts.  So after reading a couple of articles on InfoPath and wanting to play with it, I designed a form for dasBlog submissions and created an endpoint on my web server.
 
For the initial version I came up with these core attributes for the client:
  • Simple and straight forward, little configuration. 
  • Post only functionality (I can refine the posts using the web UI if I need to, and will possibly add addtional functionality later)
  • Acts like Microsoft Word (spell check, formatting, etc) when composing
  • Save posts off to file system, so I can evolve it over multiple revisions if needed, or I don't have a readily available internet connection.
  • It must use the HTTP protocol for the post submission (that way I can post reliably from anywhere with an internet connection)
 
Don't get me wrong, dasBlog already supports a great deal of these features and is a solid thin client editor.  However, I really needed the ability to compose posts offline, and persist them to file for later publishing when I was back online.
 
Actually this post right here is the product of what I created.  This is the inaugural post.
 
After I refine it, I will release the InfoPath form and dll endpoint so others can use it for their dasBlog driven sites.

SAF Day 3 - Recap

Wednesday, November 12, 2003 9:07:52 PM (Central Standard Time, UTC-06:00)

SAF day 3 was much more of the same... Keynotes and discussion groups.  It was great for networking, but from a content stand point, it was OK.  I had seen a lot of the content through the APB(Architecture Partner Board) and the discussion groups varied based on who you had in the group.  Some were very good quality while other were not impressive at all.

SAF Day 2

Wednesday, November 12, 2003 9:04:56 PM (Central Standard Time, UTC-06:00)

The day didn't start to well... on my commute from my hotel to the Microsoft campus someone hit the rental car I was driving, so I spent the majority of the morning taking care of that.  I missed the morning keynote that dug more into SOA and was basically the second half of the Pat Helland's presentation.  Luckily I had seen most of that back in August when he was working on the initial draft.

I arrived at the conference center just before an informative session on writing client applications on the Longhorn platform using some of the new stacks (Avalon, Indigo, WinFS).  Although this is a long way off, there was some pretty neat UI demonstrated.  I was also interested in the fact that Longhorn will be fully managed and allow for complete access to the OS.  The advantages that we see now in the unified BCL are the same that we will see when the OS becomes managed.

My picture with Bill at SAF...

Friday, November 07, 2003 5:04:15 PM (Central Standard Time, UTC-06:00)

OK... I didn't get a picture... but one of my co-workers at BORN (Ed Ferron) got a picture with Bill when he left the Q&A.  Nice job Ed... I knew I should have followed you.

SAF began with a welcome by Adam Denning, Director, .NET Architecture Team.  He discussed an overview of what the SAF is about, Microsoft sharing information and sharing ideas about architecture.  The initial key note was by Pat Helland... one of Microsoft's key “think tank” members.  He presented a 90 slide presentation on an analysis between how city/government and transportation progression (deemed Metropolis) of the last 200 years mirrors the evolution of technology now.  I had actually seen the presentation back in August at the APB (Architecture Partner Board) when it was about 8 hours and over 200 slides. This presentation was also shown at PDC, and you can get the slides here.

That keynote was followed by a Q&A that involved Bill Gates and Eric Rudder. 

Power of the XmlSerialization Stack

Wednesday, November 05, 2003 11:35:34 AM (Central Standard Time, UTC-06:00)

I have been working with the XmlSerialization stack on and off for about 2 years now. My first introduction to it was at DevelopMentor's Guerilla .NET @ Microsoft course back in November 2001. I had used it for trivial serialization tasks and as a simple topic for presentations that I gave internally for other consultants and at Microsoft DevCare. It was a straight forward, simple way to serialize object graphs to a human readable format (Xml).

Though useful, it was rigid and didn't always meet my requirements. In those instances I took advantage of the more robust System.Runtime.Serialization stack. After all, that stack supported private/public field serialization, highly customizable output through custom formatters and had a higher type fidelity. In addition, I could supply serialization for types that were not marked [Serializable] (through the ISerializationSurrogate).

It wasn't until the last couple of months that I really discovered that the System.Xml.Serialization stack was more flexible then I had originally thought. I stumbled across the flexibility when I was trying to emulate the ISerializable interface found in the System.Runtime.Serialization stack for an extended XmlSerializer class I was implementing to address some the original stack's short comings. I had tried implementing ISerializable on my class, then serializing it using the XmlSerializer, but none of the interface methods were called. By chance I created a IXmlSerializable interface... when I compiled, it failed indicating that the interface already existed. When I read the API docks on it, it was exactly what I was trying to implement. Prior to that I thought the System.Xml.Serialization stack was limited to a number of attributes (XmlAttribute, XmlElementAttribute, XmlIgnore, XmlArray, etc) used to describe how/what you wanted the XmlSerializer to serialize in your object graph.

What I discovered through the research is that there was more flexibility with the System.Xml.XmlSerializer then initially thought. By implementing IXmlSerializable in my classes, I could not only control how I formatted my Xml, but I could also serialize private members. Though it is a bit more work, because you must supply the implementation for not only writing the object to an XmlWriter, but also supply an implementation using the XmlReader to hydrate your object. IXmlSerializable is the equivalent to ISerializable in the System.Runtime.Serialization stack.

Granted this still doesn't give you the power that the System.Runtime.Serialization stack supplies, but it does open the door for additional implementations that may have been overlooked in the past.

Going to SAF tomorrow...

Tuesday, November 04, 2003 10:14:11 PM (Central Standard Time, UTC-06:00)

Just finished packing for my trip to Seattle.  The SAF (Strategic Architect Forum) for Partners starts tomorrow, so I am taking the 6:30am out of Minneapolis to SeaTac.  I like getting back to Seattle (after living there for 5 years), it feels familiar.  It also gives me a chance to hook up with friends from there.  Although this trip is pretty short, I am coming home Saturday morning, not staying the weekend like I did last time.

 Here are some of the session that I plan on attending while I am there:

SQL Server Next: Yukon 
Discuss the features and uses of the "Yukon" release of SQL Server. How will hosting the CLR in SQL enhance SQL programmability? How can the SQL service broker be used to deliver web services from the database? Are there pitfalls, and how can they be avoided?

Architecting for Real-time Business Intelligence 
The opportunity to profit from information is inversely proportional to the time it takes you to act on that information. How can we model applications and service portfolios to mine key data on the fly to discover interesting correlations?

Smart Client
What role should smart clients play in your application portfolio? How will the advances in the "Longhorn" programming model make smart clients more compelling? What is the migration path from Win32 to .NET to Longhorn?

Portal Solutions
A look at he good, bad, and ugly of portals -- from business-to-employee solutions to professional service automation portals. What makes good solutions succeed and bad ones fail? How can correlation and coordination across portal "parts" be used to improve the value of the solution? Where is Microsoft's portal platform going, and where should it go after that?

EAI and Integration Architecture
How can we model our existing application portfolio to discover opportunities for integration? How do we act on that model, using service facades, connectors, and legacy-integration technologies?

I will try to blog while I'm there but the schedule looks pretty packed. 

Slides for the Application Blocks MSDN Webcast

Sunday, November 02, 2003 10:21:35 PM (Central Standard Time, UTC-06:00)
Here are the slides for the MSDN Webcast that Jeff Kryzer and I presented last week.   You can download the webcast from here.

Download: AppBlocksWebCast-FINAL.zip