Infovark Underground

  • news
    • infoblog
    • underground
  • product
  • download
  • buy
  • support
  • about
  • WCF

    • Looking for an IIS Alternative

      01 Dec 2009 by Dean / 5 Comments

      One year ago it became clear that Infovark had outgrown the Windows Communication Foundation (WCF).

      We’d decided to use WCF because we wanted Infovark to provide web services, and we liked the fact that we could deploy WCF to client machines. Since WCF is built directly on top of HttpListener, a core part of the Microsoft .NET Framework, we wouldn’t need to use System.Net or Microsoft IIS.

      But we’ve struggled with WCF for a variety of reasons. First, we wanted to use a REST model for our web services, and WCF’s support for REST architectures lags behind its SOAP support.

      Second, there’s no easy way to return HTML from WCF. We tried transforming our XML with XSLT and returning the XHTML results as a Stream. This works, but the programming experience is frustrating.

      Last, because of the previous two reasons, we were left with a website that was way too rigid and programmer-like. It didn’t feel like an organic website. The tool we’d picked was forcing us to compromise on our website design goals.

      Infovark’s primary mission is to help human beings, not other computers. That means that the look and feel of the web interface should be our number one priority. Awesome web services are nice to have, but happy users are more important.

      Web server alternatives

      So for the past few months, we’ve been hunting for an alternative web server. We can’t use IIS because its footprint is too heavy. Most IT departments won’t allow us to install IIS on client machines.

      We could use Apache. It has a nice embeddable version, but interacting with it via C# is tricky. We’d prefer something a little more Microsoft-native.

      That basically leaves us with one commercial option and two open source options.

      1. UltiDev Cassini is a commercial product that’s been around for some time. We’re sure it could do the job, but the licensing model is cost prohibitive.
      2. C# WebServer is an open source project on CodePlex. It’s been around for two years, but the pace of development seems slow.
      3. Open Rasta is the brain child of Sebastien Lambda, an open source framework for the development RESTful development of web sites and services. It’s been getting a lot of attention recently.
      4. Kayak is a promising open source project, but it hasn’t reached its first public release yet.

      (If you know of other web servers worth investigating, please let us know in the comments!)

      Making the switch

      More important than picking an alternative web hosting framework for Infovark is the timing of the switch. We don’t want to impede future development.

      As a stopgap, we might try plugging in the Spark View Engine to replace our current XML-XSLT-XHTML rendering path. Who knows? If it improves our web development flow, we might be able to keep our WCF base after all.

      Continue Reading

    • Using WCF to return HTML

      18 Feb 2009 by Dean / 1 Comment

      I just answered a WCF question on StackOverflow, and decided it was worth cross-posting here as well.

      The question was: What is the best / most flexible way to have WCF output XHTML?

      Here’s how we do it at Infovark. While I’m not sure that our approach is the best way, it does the job.

      Our approach is to use the DataContractSerilizer to generate XML, then apply a Complied XSLT transform and return the result stream, which should now contain XHTML. Here’s a simplified version of our code:

      1.     public Stream GetItemAsHtml(string id) {
      2.         Item obj = GetItem(objectId);
      3.         Stream xml = GetXmlStream(obj);    
      4.         return TransformXmlStream(xml, defaultTransform);
      5.     }        
      6.  
      7.     public static Stream GetXmlStream(IXmlSerializable item) {
      8.         MemoryStream stream = new MemoryStream();
      9.         using (XmlWriter writer = XmlWriter.Create(stream, new XmlWriterSettings { Encoding = Encoding.UTF8 })) {
      10.             if (writer != null) {
      11.                 DataContractSerializer dcs = new DataContractSerializer(item.GetType());
      12.                 dcs.WriteObject(writer, item);
      13.  
      14.                 writer.Flush();
      15.                 writer.Close();
      16.             }
      17.         }
      18.         stream.Seek(0, SeekOrigin.Begin);
      19.         return stream;
      20.     }
      21.  
      22.     public static Stream TransformXmlStream(Stream xml, string xsltFile) {
      23.         XmlReader reader = XmlReader.Create(xml);
      24.  
      25.         XslCompiledTransform trans = new XslCompiledTransform();
      26.         trans.Load(xsltFile);
      27.  
      28.         MemoryStream stream = new MemoryStream();
      29.         using (XmlWriter writer = XmlWriter.Create(stream, trans.OutputSettings)) {
      30.             if (writer != null) {
      31.                 trans.Transform(reader, writer);
      32.  
      33.                 writer.Flush();
      34.                 writer.Close();
      35.             }
      36.         }
      37.         stream.Seek(0, SeekOrigin.Begin);
      38.         return stream;
      39.     }

      It works for us, but if you’ve got other, better ideas, please let me know!

      Continue Reading

    • Categories

      • .NET (41)
      • AJAX (3)
      • Books (7)
      • HTML (9)
      • Infovark (8)
      • Programming (48)
      • REST (11)
      • SQL (3)
      • Testing (3)
      • Tools (13)
      • UI (3)
      • WCF (11)
      • Web Services (8)
      • WPF (4)
      • XML (4)
    • Archives

    • Get future articles


       

    • Blogroll

      • Ajaxian
      • Anne Van Kesteren
      • Brain.Save()
      • Coding Horror
      • Eric Sink
      • Joel Spolsky
      • John Resig
      • Mark Pilgrim
      • Raymond Chen
      • Scott Hansleman
      • Secret Geek
      • Steve Yegge
      • The Daily WTF
      • The Database Programmer
    • Meta

      • Log in
      • Entries RSS
      • Comments RSS
      • WordPress.org
  • Site map

    • News
    • Product
    • Download
    • Buy
    • Support
    • About
  • Recent Posts

    • Review: Brownfield Application Development in .NET
    • Using Modal Dialogs with a Splash Screen in WPF
    • Highlighting query terms in a WPF TextBlock
    • Getting XAML Hyperlink text to wrap
    • How to format the XAML Hyperlink NavigateUri
  • Twitter

    Copyright 2011 Infovark, Inc. All rights reserved.