If your a developer that spends any time with web services, you’ll basically probably end up working in one of two camps: REST- or SOAP-based services.  Now with SOAP services you’re likely used to having a WSDL document describing the service, providing type definitions, etc. – something you can use developer tools like Visual Studio to Add Service Reference and get a strongly-typed object model to work with.

If you’ve been doing Silverlight or ASP.NET (or any other technology really) development with mashup services, you probably have been working with REST-based services.  These are services that don’t self-describe themselves in a manner like SOAP with WSDL does.  Often I’ve found that really only the larger REST service providers provide good documentation for their services.  As a consumer of a REST service, you’re at the mercy of the documentation to understand the structure of the requests/responses that you’ll be working with…at times that can be frustrating.  If you are like me, you’ve probably either found someone else’s wrapper to the API or tried to work some other method to avoid spelunking the XML nodes.

If you don’t need to take on the full wrapper that you may have found someone already doing and maybe just need to consume something quick or whatever, enter Paste XML as Types.  Located in the WCF REST Starter Kit Preview 2, this is a Visual Studio new option under the Edit menu.  Let’s take a look at an example.

Twitter sounds like it would be a good example, but honestly they provide so many different formats (JSON, XML, RSS) that I’m not sure you would really want the XML version when RSS is more of a known type and easy to work with.  So let’s look at the Flickr API which is a similarly popular one and has a well-documented REST interface.  Let’s say you wanted to work with the results of their ‘interestingness’ public query which will provide you with a list of photos.  We can see in their documentation that they provide us with a sample response:

   1: <photos page="2" pages="89" perpage="10" total="881">
   2:     <photo id="2636" owner="47058503995@N01" 
   3:         secret="a123456" server="2" title="test_04"
   4:         ispublic="1" isfriend="0" isfamily="0" />
   5:     <photo id="2635" owner="47058503995@N01"
   6:         secret="b123456" server="2" title="test_03"
   7:         ispublic="0" isfriend="1" isfamily="1" />
   8: </photos>

Sweet.  Copy that sample response.  Go into Visual Studio in your project class file (or create a new one), go to the edit menu:

Paste XML as Types

Booyah!  Watch as the magic happens and the XML structure is transformed into strong types for you.

Well, sorta.  Turns out while I think this is a cool feature, it might have some work still to go.  My first assumption was that the documentation on Flickr matched exactly the response (heck, it says sample response).  But it really is only the response body.  There was some missing response header nodes.  You should call the API directly to see a real response.  Second, even with that it looks like I’m getting some weird namespace stuff.

But regardless of that, even taking an XML file and being able to reflect on that to create an object model on paste is pretty cool. 

Try this out – if you see issues leave comments on the WCF REST Starter Kit site so they can see them – you’re welcome to leave them here as well, but I’m not on that team and it’s better to give direct feedback on their project.

Last week I was wanting to do something on my site sort of a ‘breaking news’ style banner that would span the entire site width but only when I wanted it too – based on a cookie or something else.  And I didn’t want to do something server side, because I was sick of doing stuff like that.

Not having played with jQuery, I thought I’d take a dive.  Prior to MIX09, I’d been testing something that the MIXOnline team had been toying with, which has just been released: Glimmer.  Glimmer is described as a jQuery Interactive Design Tool.  A helper for those like me who know nothing about it.  Sure, jQuery has a ton of resources, and my Twitter peeps came through helping me navigate some of the things that aren’t glaringly obvious for noobs like me :-).

But Glimmer got me started, and I think that’s the point.  I had an overall HTML structure already and had the div element that I wanted to work with in jQuery – my goal was to animate it in a ‘breaking news’ sort of manner (or at least what’s in my head when I think of that concept).  I opened up my HTML in Glimmer and went to work.  I simply added the action (the function I wanted to trigger), then pointed it to the element to target.  Here’s what my simple Glimmer UI action setup looked like:

Glimmer UI

I clicked save and it created a JavaScript file for me with the completed code:

   1: jQuery(function($) {
   2:  
   3: function loadBreakingNews(event)
   4: {
   5:      $("#info").css("top","-50px");
   6:     $("#info").animate({"top":0}, 894, "easeOutBounce", null);
   7: }
   8:  
   9: loadBreakingNews();
  10:  
  11: });

Sure, to you jQuery pros, this looks simple, but this tool helped me quickly use a design-time tool to generate this without previous knowledge of jQuery.  Now, I’ve learned a few things about jQuery since my first incarnation – all of which took 2 seconds with Glimmer.  I decided I wanted to use the built-in “slideDown” feature in jQuery.  Some things like this aren’t supported in Glimmer yet, but simple things are…and quite frankly, the combination of Y position animation and an easing function accomplished the same goal.

I made a few hand-modifications to fit my needs (checking for cookies to trigger the banner, etc), but Glimmer got me started right away figuring things out quickly…it was awesome.  I think it comes with a free ShamWow as well, I’m not sure, but I swear Karsten told me that. :-)  Check out Glimmer today if you are new (or even seasoned) to jQuery.  There is a plugin model I haven’t explored, but check out the Glimmer project site for more information.

Next maybe I should explore working with jQuery and Silverlight as I know there is more to jQuery than animations and I think it would make a helpful library for the HTML interop layer.

It’s that time of year my friends in Arizona.  No, I’m not talking about when the air conditioners start get turned on, nor how the golf green fee rates are reduced or the snowbirds fly away…although those are good things as well.

I’m talking geek fest time.  Mark your calendars:

26 May 2009 – 8:00 AM

The community leaders in the area have organized another big event for your benefit.  So who is coming?  Here’s the rundown:

Glenn Block – come see why you should get addicted to MEF.  Don’t know what it is?  That’s an even better reason to come.  If you haven’t learned about MEF, you’ll want to see what Glenn has to show and talk about…it’s quite cool.

Jaime Rodriguez – from the WPF side of the house, Jaime is coming to talk about WPF development and the continuum of reusing skills (and some code) from Silverlight and WPF development.  Want to know what is going on in the WPF world?  Come and ask Jaime. 

NOTE: Also don’t forget to register for the Phoenix WPF training event for free as well! Info here and Register here for the WPF LOB Tour.

And last but not least…

Scott Guthrie – he returns to brave the early heat of the desert!  Scott is ready to talk about Silverlight and ASP.NET MVC frameworks and what his teams are up to.  Bring your questions and take advantage of this opportunity to talk with the one responsible for building the web platform for Microsoft.

This truly sounds like a great event and one NOT TO MISS!  Tell your co-workers and friends.  This is a free event!  You can register for this event here.  Please come and spread the word to support this community event.  Your community leaders will thank you (and be able to do more things like this for the community).

Spread the word! REGISTER

There seems to be a lot of buzz around Silverlight lately and I admit, I like it :-).  But I also think that there is a huge misconception about Silverlight “replacing” WPF.  I get emails a lot about people asking me questions about Silverlight and after a bit of prodding, I see that their target platform for their application is Windows.  I then begin my rant on why it should be WPF if that is the target platform.  I’m usually met with some weird looks being that I do a lot of Silverlight, but I state my case accordingly.

The conversation usually follows about not understanding WPF or trying to find more information about it.  Well, the WPF teams are trying to change that perception.  In fact, Jaime Rodriquez and Karl Shifflett have been organizing a WPF LOB Tour to provide 2 days of free WPF training for developers.  Jaime is the technical evangelist for WPF and Karl works on the WPF team.  They will be in these cities soon:

  • Los Angeles, CA
  • London, UK
  • New York, NY
  • Chicago, IL
  • Phoenix, AZ

Take a look at what they’ll be covering about WPF:

  • Day One:

    • Lap Around WPF
    • WPF Tools ( Blend, Visual Studio 2008)
    • Graphics Subsystem
    • Layout
    • WPF Fundamentals and new concepts
      • Application Model
      • Dependency Properties
      • Trees (logical & visual)
      • Events
      • Threading
      • Resources
    • Controls
    • Styling
    • Templating
    • Q&A with instructors at end of day
  • Day Two:
    • WPF integration with Win32 and Windows Forms
    • Data binding
    • Introduction to Model-View-ViewModel
    • Commanding in M-V-VM
    • Views, Navigation and Transitions
    • Data Validation
    • Error handling, Model dialogs, Logging
    • Unit Testing
    • MVVM & LOB tips and tricks
    • Q&A with the instructor
  • If this is coming to an area near you, I’d strongly encourage you to make the time to be there.  There is no cost to you other than getting yourself there (if it isn’t in your same city).  Their first event packed a full house on registration within 2 hours and the feedback from the training was overwhelmingly positive and exciting.  Karl is such a dynamic and fun guy to be around, it will be worth your price of admission to hang out with him and Jaime for 2 days.  I’d love for one city to rally together and all show up wearing Hawaiian shirts to make Karl feel at home :-).

You can find all the information about the events on Karl’s blog or Jaime’s blog.  Registration links and everything are listed there.  If you have a question about the event, please reach out to Karl or Jaime.  I know their most asked question is "why aren’t you coming to <fill-in-the-blank-location>?  Honestly after talking to Karl I’m convinced he wouldn’t sleep if he could go everywhere…and he wants to as well!  I think there are some plans to do some studio recordings and produce the information online, but there is no timeframe for that just yet…and I do believe that nothing really supplements being able to network with others learning and being in-person to ask questions, etc.  It’s a great opportunity to learn and demystify WPF development for yourself…really, make the time to be there.

Additionally, there have been some organized XAMLFest events happening around the country (US – but if there are others worldwide, leave a comment where they are happening).  These aren’t 2-day workshop trainings, but are events organized around our XAML technologies, specifically WPF and Silverlight. 

I think WPF and Silverlight are really great technologies and compliment each other well.  Try not to learn one without the other.  I know personally I’m trying to do more WPF learning myself as the natural progression of the Microsoft platform is the continuum of Silverlight to WPF as shared application platforms.  I hope you’ll do the same.

If you’ve attended one of these WPF events listed above, please leave a comment about your feedback as well. 

I’ve been promising this for a while and I’ve ranted about creating good installation experiences for Silverlight applications before as well here and here.  Well, our team rallied and created some new guidance and sample code to provide for you to implement the best possible experience.  The guidance whitepaper can be found on the Silverlight Community Site in the whitepapers section and includes:

  • Documentation for defining a good user experience
  • Sample code for media applications
  • Sample code for non-media applications
  • Sample code for implementing various states: not installed, upgrade needed, browser restart detection

The sample code is easy to understand and was templated so that you could change things to your brand/application.  The media sample can be dropped into your Expression Encoder templates easily and does a lot of the magic for you without having to thing (i.e., getting sizes of media, snapshot of media for image, etc.).

Hopefully this will help you understand the process more and provide you with the information (and code) you need to complete the best possible experience in your site.  You’ve spent the time developing your application, make sure you spend the time delivering the best install experience for those who may not have Silverlight yet.

Download the whitepaper and code today.

Hope this helps!