Welcome to MSDN Blogs Sign in | Join | Help

If you try to install the Internet Explorer Administration Kit on a Virtual PC image you may have probably encountered the following situation

disk_space

The box shown above appears and stays there forever. The only option you have is to click the “Return” button and cancel the installation process. But as you may still want to have this piece of software installed on your virtual pc you are pretty much stuck here. However there is at least still one possibility to install the .msi package. That is by using the msiexec.exe tool with the quiet or passive option. So after opening a Command Window (eventually as Administrator) you can use the following command line to silently install the IEAK install image:

msiexec /quiet /i <PATH>\ieak.msi

This will install the package and it will be available for use. However there is one problem with this approach. In the GUI you need to choose a license type from three options (Internet Service Provider (ISP), Internet Content Provider (ICP) and Corporate). With the above method you cannot do that and therefore the product is installed with the default license which obviously is the ISP license. Implication of this is that there are certain features enabled or disabled in IEAK depending on the license mode. So if you need the ICP or the Corporate mode you are stuck again. However as a quick hack you can modify one (or better) two registry key in order to adapt IEAK to your needs and requirements.

You need to go to:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\IEAK

And then there are the two string values which you can modify:

Mode: <0|1|2> where 0 is ISP, 1 is ICP and 2 is Corporate

Organization Name: Which is the name that gets inserted in certain UI areas of IE and which probably has also some legal meaning with respect to licensing.

So finally it will look something like this which is the correct setting for your requirements and you then are ready to start creating custom IE8 packages.

ieak_reg

I already blogged quite a bit about the new Visual Search feature in Internet Explorer 8. Since this needs some customizations on the server side in order to create search responses that correspond to the Visual Search standard and are either in JSON or XML format changes are good that your search already is able to provide the search results in RSS format.

And if this is the case you can easily add an entry to your existing OpenSearch descriptor file to include the URL template for the RSS search response. And then you could use exactly that same file in order to publish and distribute it as an Federated Search Connector for Windows 7.

To create a RSS template URL that can be used with Windows 7 the same parameters are valid as for the visual search or a standard web search provider and adhere to the OpenSearchDescription specification. So such a URL template could look like the following (with Bing search as an example).

 
Of course even if you do not already have a IE8 Visual Search but a RSS response mode for your search you still can use it with Windows 7. The minimal configuration that you provide a “ShortName” and the template URL. The rest is optional however it is recommended that you add also a standard web search template so that Windows 7 displays a button to let you start a standard web search eventually using different parameters.
 
 image
So a valid and minimal open search configuration for use as a Windows 7 search provider that searches my blog would look something like this:
 
<?xml version="1.0" encoding="utf-8"?>
<OpenSearchDescription xmlns:ms-ose="http://schemas.microsoft.com/opensearchext/2009/" xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Come Get Some...Search</ShortName>
<Url type="application/rss+xml" template="http://api.search.live.com/rss.aspx?source=web&amp;query={searchTerms}+site:http://blogs.msdn.com/astrauss" />
<Url type="text/html" template="http://www.bing.com/search?q={searchTerms}+site:http://blogs.msdn.com/astrauss&amp;go=&amp;form=QBRE&amp;scope=web" />
<Description>Windows 7 Search Connector for the Blog of Alex Strauss</Description>
</OpenSearchDescription>

As you may realize it is quite simple to create such a configuration. Then you can provide it as a file using the .osdx extension. If you provide as a URL the Mime-Type is already registered and the user can directly install the provider from a simple link.
 
So if you want to add the search provider for my blog then click the link below.
 
 
 
And to make it even easier for you to create your own configuration file I created a little Silverlight application that creates a configuration XML from the parameters you provide. Unfortunately as I’m not able to host ASP.Net applications you have to copy&paste the XML string to a text editor. However I hope you like it anyway.
 

As the release schedule of our Enterprise RIA template and sample application was a little bit unfortunate we now had the time to update the project. We needed to do some changes to the code which we couldn’t do before now due to some time constraints. For example the way ton include application services into the app changed quite a bit. The way to declare the service in XAML was using the attached property

<Application.Services>

a full example of the “old” way is posted here. The new way to declare an application service is to use the

<Application.ApplicationLifetimeObjects> attached property. But not only the name of the property changed there are more changes to that concept including the mechanisms to obtain an instance of such a service. Now you can simply query the ApplicationLifetimeObjects collection e.g.  using extension methods.

public static IUnityService GetUnityService(this Application application)
{
return application.ApplicationLifetimeObjects.OfType<IUnityService>().Single();
}

Another full example is posted here.

However now the updated version finally does run on the release version of the Silverlight 3 Runtime.

In addition I attach the code here as the push out onto the mymsdn site may take some time.

Please remember that you may need to update some references to assemblies which are not included in the project such as the Unity or the Silverlight Toolkit.

Due to some recent changes in licensing for LyricWiki to provide song lyrics via web service calls my famous Radio GaGa Silverlight application does no more show lyrics of the selected songs. As said this is due to some restrictions made by the music publishers and is neither my nor the fault of LyricWiki. While this is just a sample application it is not too much of a problem at all however I just wanted to make you aware of this. I’m reflecting now how I can change the application to still add some value. For example the web service still returns discographies and other artist/song related information.

So if you have any ideas on how to pimp Radio GaGa I would appreciate if you’d leave a comment. Until then stay tuned and at least leave out one purchase of music to show the publishers that consumers still have a voice. Or better send them a note and tell them that they still don’t know how the internet works.

Jörg an I created a new RIA Template and sample application for enterprise applications based on Silverlight 3 and the Silverlight Toolkit.

This Visual Studio template and sample application provides a basic structure with sample code for an Enterprise RIA. The intention of providing this was to show how Microsoft Silverlight 3 can be used to create Rich Internet Applications (RIAs) in an enterprise environment. This means e.g. to effectively visualize enterprise data and provide functionalities which may allow to better work with and manipulate such data in comparison to traditional web applications. The focus when designing this template and sample was on the following two main subjects:

  1. Make use of the latest Silverlight technology and Silverlight extensions such as the Silverlight Toolkit or the Silverlight port of the Unity container in order to get to working results as fast as possible while preserving a high level of quality.
  2. Design and implementation of the application following some proven architectural patterns and software development techniques in order to provide code that meets usual requirements in enterprise application development in order to provide a baseline that can be used to create own custom enterprise RIAs on top of it.

The sample application deals with financial data and stock trades. It exemplary implements certain aspects of visualizing of data which can be relevant and helpful while buying or selling stocks and managing accounts.

The functionality of the sample application is best described using a screenshot of the application itself.

image

  • RSS ticker with detail view using visual effects which are rendered with GPU hardware support
  • Possibility to filter the available data via ComboBox (timeframes) and textbox (ticker symbol)
  • Accounts are displayed and selectable in a TreeView control
  • Scatter graph for clear display of transactions and transaction cluster (resolution is per day)
  • Transaction nodes in the scatter diagram show the value of the transactions (or sum if its a transaction cluster) via mouse hover effect. A detail view is also available and is shown after clicking a node in the graph
  • Line graph that shows all stocks in the account evaluated with the respective stock price at that day in order to visualize the overall account value which is explicitly shown when hovering over the line graph nodes
  • Tabular view of the transactions in a certain timeframe or of a certain stock with detail view
  • Tabular view of a stock ranking for the selected timeframe regarding their performance showing performance figures, highs and lows with the respective dates

This template and sample application is based on

and was developed using

The architecture of the application is, besides others based on the following patterns and techniques

  • The ViewModel pattern (a MVC variant) to decouple the UI and the application logic as much as possible
  • Comprehensive data binding via collections implementing the observer pattern. Therefore we were able to implement the sample without any references to UI components in the C# code
  • Almost no use of custom events for notification
  • Use of Unity a dependency injection container infrastructure which manages certain application components and services during their lifecycles and provides concrete instances of those artifacts when those are needed during runtime

More in depth and technical details to this implementation and techniques can probably found soon in theses blogs:

· Blog of the Microsoft Technology Center Munich

· Blog of Jörg Joos

· Blog of Alexander Strauß

The template and sample application can be found here on MyMSDN or just drop me a note. Due to some time constraints it is still based on Silverlight 3 Beta however we will provide a SL 3 release version pretty soon.

I took some more time to enhance Radio GaGa, the sample application from my last post. It now supports search, has a home button, artist paging functionality and an updated layout and was updated to work with the final Silverlight 3 runtime.

And as I was evaluating the current Windows Azure SDK I thought it might be an interesting idea to deploy Radio GaGa onto the Azure Fabric as is. My guess was that it must be a straight forward process as this is a Silverlight only application that uses no Azure Services or resources besides the basic hosting. So I tried it and unlike some other tries where I thought everything should be quite easy and straight forward this time it really worked well. So here it is. Remember to get the Silverlight 3 runtime in order to use the application.

And as always if you would like to get the Source Code for this sample application feel free to contact me.

 

Radio GaGa Link

During the last few weeks I was working with Silverlight again quite a bit. This meant I had to write some code for several showcase projects, too. Of course no real production code (beware) but nevertheless in the end the applications were doing what they were supposed to do. However as it usually happens in those cases you have to decide between a quick and dirty fire and forget kind of stumble into the programming of the app or to put some basic effort in planning and designing to have at least the basic rudiment of an application architecture. And although I’m in the role of architect evangelist I’m always tempted to start coding without big thinking right away. This time however we took some time and designed our applications so that we would have a nice separation between UI and application logic. In particular we chose a ViewModel approach which is quite common in the world of WPF and Silverlight. ViewModel stands for Model-View-ViewModel (MVV) and is a variation of the widely known Model-View-Controller (MVC) pattern. I won’t dig deep into the explanation of this patterns as they have been described in depth at many places already including John Gossman’s or David Hill’s Blog for MVV or the Portland Pattern Repository for MVC. This said I want to focus on a short example driven walkthrough on how to create an Silverlight Application implementing the MVV pattern.

 

The example application allows to view songs and song lyrics of the current top artists listed on LastFM. In order to aggregate the data this small sample application already is a mash up of two different web services.

So in order to give you a high level impression of the application here is a simple architecture sketch.

Architecture Sketch

The Visual Studio 2008 project is organized accordingly. To maintain the highest level of simplicity a service access layer has been omitted although this would be something you would probably want to consider in a real application development project.

Project Structure

The folders contain the following:

  • Icons contains the icons for the Silverlight 3 out-of-browser feature as I enabled OOB for this sample app however it is obviously not relevant for the ViewModel part
  • Model contains, well, the ViewModel class and any other class necessary to build the object model for this application. In this case those are classes like Artist and Track which mainly consist of private fields and the related public properties.
  • Views contains the UI which in this sample is a single XAML page with it’s code behind
  • Servicedata contains some constant REST URIs for the services I call

As this baseline structure could be already called something like a best practice for ViewModel projects one could use such a structure as a base template for such applications.

Now let’s start with the meat of the application. The best way to start off with would probably be to create an empty ViewModel class stub which basically is a standard C# class stub. Next step could be to create something like a ViewModel Base class which enables change notification for properties of the ViewModel. This is absolutely helpful in order to have your views automatically updated when the properties change to which any UI Element is bound to.

This would look something like this:

public abstract class ViewModelBase : INotifyPropertyChanged
{
    protected void OnPropertyChanged(string propertyName)
    {
        PropertyChangedEventHandler handler = PropertyChanged;
        if (handler != null)
        {
            handler(this, new PropertyChangedEventArgs(propertyName));
        }
    }
 
    public event PropertyChangedEventHandler PropertyChanged;
}

So the ViewModel then extents this ViewModelBase class and instantly gains those notification capabilities when the OnPropertyChanged method is called in the setter of a property.

The same requirement also exists for collections which are data bound however this is almost even easier as Silverlight (as well as WPF) comes with a special collection class which implements the Observer pattern which of course is tightly related with any MVC pattern. This class is a generic collection class and is called ObservableCollection<T>. So with this knowledge we can start filling our ViewModel with life. For this sample this would look like the following up until now:

public class RadioGaGaViewModel : RadioGaGa.Model.ViewModelBase
    {
        #region Fields
        private ObservableCollection<Artist> topArtists;
        private ObservableCollection<Track> topTracks;
        private string currentLyrics = string.Empty; 
        #endregion
 
        #region C'tor
        public RadioGaGaViewModel()
        {
            this.topTracks = new ObservableCollection<Track>();
            this.topArtists = new ObservableCollection<Artist>();
        } 
        #endregion
 
        #region Properties
        public string CurrentLyrics
        {
            get { return this.currentLyrics; }
            set
            {
                this.currentLyrics = value;
                OnPropertyChanged("CurrentLyrics");
            }
        }
 
        public ObservableCollection<Track> TopTracks
        {
            get { return this.topTracks; }
        }
 
        public ObservableCollection<Artist> TopArtists
        {
            get { return this.topArtists; }
        } 
        #endregion
    }

Now what we have to do next is to make the ViewModel available to the UI for data binding. This can be easily done by following this little sequence of tasks:

  • Register an event handler for the Loaded-Event of the UserControl in the XAML markup of the respective view.
<UserControl
    ...
    x:Class="RadioGaGa.MainPage" 
    Loaded="OnMainPage_Loaded">
  • Create a handler method stub in the code behind file of the XAML page
private void OnMainPage_Loaded(object sender, RoutedEventArgs e)
        {
            
        }
  • Instantiate a new ViewModel object
private void OnMainPage_Loaded(object sender, RoutedEventArgs e)
        {
            RadioGaGaViewModel model = new RadioGaGaViewModel();
            
        }
  • Create a public property which sets the DataContext for the UserControl
public RadioGaGaViewModel ViewModel
        {
            get { return DataContext as RadioGaGaViewModel; }
            set { DataContext = value; }
        } 
  • Set the property and assign the ViewModel instance you just created
private void OnMainPage_Loaded(object sender, RoutedEventArgs e)
        {
            RadioGaGaViewModel model = new RadioGaGaViewModel();
            ViewModel = model;
        }

After doing all this you can bind your the properties of your UI controls to the Properties of your ViewModel which are surfaced to the controls via the DataContext set on the top level FrameworkElement. For example you could create a DataTemplate for the items of a ListBox and could bind the respective properties like shown in the sample below.

<ListBox.ItemTemplate>
    <DataTemplate>
        <Border CornerRadius="5" BorderThickness="1" BorderBrush="Black" Margin="1,0,0,1" Padding="2" MinWidth="320">
            <Border.Background>
                <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                    <GradientStop Color="#FFB2B2B2"/>
                    <GradientStop Color="#FFFFFFFF" Offset="1"/>
                </LinearGradientBrush>
            </Border.Background>
            <Grid Height="55" HorizontalAlignment="Left">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MaxWidth="40" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <StackPanel Orientation="Vertical" Grid.Column="0" MaxWidth="40" HorizontalAlignment="Left">
                    <TextBlock Text="{Binding Path=Rank}" FontSize="12" FontWeight="Bold" Foreground="Black" TextAlignment="Left" VerticalAlignment="Center" Padding="5,0,0,0" />
                    <Image Source="{Binding Path=Images[0]}" Height="30" Width="30" HorizontalAlignment="Left"/>
                </StackPanel>
                <StackPanel Orientation="Vertical" Grid.Column="1" HorizontalAlignment="Left">
                    <TextBlock Text="{Binding Path=Title}" FontSize="12" FontWeight="Bold" Foreground="Black" TextAlignment="Left" VerticalAlignment="Center" Padding="5,0,0,0" />
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="Artist:" FontSize="12" Foreground="Black" TextAlignment="Left" VerticalAlignment="Center" Padding="5,0,0,0" />
                        <TextBlock Text="{Binding Path=Artist.ArtistName}" FontSize="12" Foreground="Black" TextAlignment="Left" VerticalAlignment="Center" Padding="5,0,0,0" />
                    </StackPanel>
                    <TextBlock Text="{Binding Path=Playcount}" FontSize="12" Foreground="Black" TextAlignment="Left" VerticalAlignment="Center" Padding="5,0,0,0" />
                </StackPanel>
            </Grid>
        </Border>
    </DataTemplate>
</ListBox.ItemTemplate>

And that’s basically all for creating a ViewModel pattern based architecture. Next step would be to implement the business logic that fills the ViewModel properties. In my case these are the calls to the different REST based web services, which of course are called asynchronously (also as Silverlight doesn’t support anything else) in order to still have an responsive UI while the services are accessed.

For our sample the final result can be tested here: http://www.level70.de/silverlight/RadioGaGa/RadioGaGa.html

As I already equipped my development machines with Silverlight 3 Beta this only works with the SL3 Beta runtime. So if you are still on 2 you have to be content with this screenshot (pretty, eh? ;))

screenshot

The Visual Studio 2008/SL 3 Beta Tools solution can be downloaded from my SkyDrive.

I hope this all is helpful and easy to understand. As always feel free to send comments or corrections, etc.

Two more Sidenotes:

  1. LyricsWiki also offers a SOAP web service however I was not able to use it with Silverlight when letting Visual Studio generate the service proxy (with svcutil for Silverlight probably). So I switched to the REST based version
  2. This project can quite easily be migrated to WPF and vice versa. I’ve done this two time due to the fact mentioned in <1> because I wasn’t aware of the REST interface in the beginning. This shows that WPF and Silverlight get closer and closer with their features and APIs so that a develop once run everywhere scenario will become more and more feasible.


DeliciousBookmark this on Delicious Share  

Due to quite some unexpected demand for the sources of the knowledge management showcase published in this blogpost even now almost 2 years after the initial post I took some short time and updated the solution. So now should at least rudimentary work with Silverlight 2 and 3 Beta.

Unfortunately I had to strip out dragging support because I was constantly experiencing System.Argument.Exceptions when calling the MouseEventArgs.GetPosition() method and didn’t want to invest to much time into debugging.

So for me the solution basically works including the HTML-Search Button that calls into the Silverlight application however there is still no optimized or well documented code. It was and still is a quick hack and only should demonstrate how to innovatively visualize dry business content. So use at your own risk and feel free to send me comments or optimized versions. ;)

 

You can download the solution here.

Not just in order to show that this Blog is still alive but also because it may be a little useful hint for all of you doing the first steps with M, the language of the Oslo Developer Center.

As you might already know you can create data models with M which are parsed and transformed into T-SQL Reference by the M-Parser.

Not only can you define Types & Values but can also assign a storage container for the defined types. Depending on the Grammar used to translate the M-File it is transformed in something that provides real storage e.g. a table in a relational database.

In the following snippet the extent definition is marked in red.

   1:  module MyModule {
   2:      type OrderItem {
   3:          Description : Text;
   4:          Quantity : Integer32;
   5:      }
   6:      OrderItems : OrderItem*;
   7:  }

In the sample above M does not care about how the storage is physically populated. In case of using the T-SQL variant this line would only create the table but wouldn’t insert any items (which is absolutely comprehensible behavior). However sometimes it could make sense to also initialize the storage with some values. And therefore M supports what is called extent initialization. And this works for all types supported by M and the respective data store.

So you could easily define an extent initalizer for the following type.

   1:  type Task
   2:  {
   3:          Id:Integer32 = AutoNumber();
   4:          Name:Text;
   5:          DueDate:DateTime?;
   6:          Owner:Text;
   7:  } where identity Id;

However if you wonder what format to use for the DueDate field and stumble across the example documented in this MSDN documentation you will probably end up with an error message like shown in the screenshot below.

image

The issue here is that DateTime is specified following the following lexical structures for Date & DateTime literals.

Date literals are used to write a date independent of a specific time of day.

DateLiteral:

                Signopt  DateYear  -  DateMonth  -  DateDay 

The tokens of a DateLiteral must not have whitespace.

DateDay: one of

                01  02  03  04  05  06  07  08  09  10  11  12  13  14  15

                16  17  18  19  20  21  22  23  24  25  26  27  28  29  30

                31

DateMonth: one of

                01  02  03  04  05  06  07  08  09  10  11  12

DateYear:

                DecimalDigit  DecimalDigit  DecimalDigit  DecimalDigit

So the cause for the error is obvious as there is the sample only states a single digit for DateDay. So changing this to a double digit variant will resolve this issue. The complete lexical structure of M can be found in the MSDN library as well.

If you want to know more about ‘Oslo’ and ‘M’ check out the MSDN Developer Center and visit the blogs of Douglas Purdy and the Intellipad Team.

With some delay here is the final part of the series on how to implement a IE8 Visual Search Service using WCF. In this last part I will deal with the small bits which are still open in order to be able to deploy a full functioning Visual Search service and those are:

  • Simple caching mechanism
  • "Spambreak" to control the number of requests that are processed
  • WCF Configuration
  • Visual Search Configuration XML
  • Webpage for adding the service to the IE search provider list

Implementing a simple caching mechanism

As already mentioned quite a few times performance is critical for a Visual Search service in order to get acceptance by the users so it is opportune to use some kind of caching mechanism. In order to follow the K.I.S.S principle I didn't want to implement a highly sophisticated caching mechanism on my own so I simply use the caching application block which is one of the components of the Enterprise Library created and published by Microsoft Patterns & Practices. The caching block allows you to integrate very effective, configurable and extendable local cache into your application. Information about the features and how it can be used is documented in the MSDN documentation. For my Visual Search service I used the simplest approach on using the cache. So it is an in-memory cache that simply adds search results as cache entries with the query string as their key. The overall simple (cache)-flow ;-) in the service is outlined in the figure below.

cache_flow

The relevant code portions are minimal.

  1. The initialization 

    ICacheManager searchResultCache = CacheFactory.GetCacheManager("Cache Manager");
  2. The check

    private bool CheckCache(string query)
    {
           return searchResultCache.Contains(query);
    }
  3. The retrieval

    sI = (SearchItem)searchResultCache.GetData(query);
  4. The addition

    searchResultCache.Add(query, sI, CacheItemPriority.High, null, new SlidingTime(TimeSpan.FromMinutes(30)));

Of course you need to be aware of the concurrency mode in which the service performs when dealing with the cache. There are two categories to take care of:

  1. Instancing

    For a service like this the instancing behavior should be set to single as this ensures that there is only one instance of the service and thus for the cache which then ensures that all requests are validated against the same set of cached items. So I set the InstanceContextMode to single.
    However if you are implementing a high scale service you need consider a slightly different approach and will probably have multiple instances that access an distributed cache or at least you will have a backing store ore some kind of replication mechanism that replicates the cache across multiple physical nodes.
  2. Concurrency

    For concurrency the most reasonable setting is probably to allow the single service instance to deal with multiple requests at a time because otherwise we would introduce significant performance constraints. This however requires that the service itself is thread safe which is not an easy task to acomplish. So for simplicity, rapid development and testing reasons I initially set the ConcurrencyMode also to single.

More about this topic can be found on MSDN.

"Spambreak" to control the number of requests that are processed

As unlimited resources in terms of scaling and workload are rarely available there may be the need to limit the number of incoming requests to a sensible amount. One good measure is to check the length of the search query. In many cases it doesn't make sense to retrieve results for a single letter or number. Therefore it could be useful to only cycle through the complete search process when the query string has passes a given threshold (e.g. 3 letters). If the length is below the threshold you can simply return a static default result which could significantly boost performance.

WCF Configuration

Every WCF service needs a configuration. Although configuration could completely happen in code it is handier most of the times to declaratively configure the service with an XML configuration. As we are using the Internet Information server as our service host we can include the service configuration details into the Web.config file and can edit it with the WCF Configuration Editor included in Visual Studio 2008 (see figure).

WCF_Config_Editor_s

As we create a restful service we need to create an rest endpoint and use the respective binding. In my case I created the configuration with the endpoint and associated binding and behavior attributes completely myself however there is also the possibility to use the Factory attribute of the ServiceHost directive.

For the Visual Search service I need to define an endpoint which in my case defaults to the default adress. Then we need to configure this endpoint with an webHttpBinding so that the service is exposed via HTTP requests and not via SOAP messages. Finally in order to allow clients to communicate via HTTP request we must attach the WebHttpBehavior to the endpoint. So the complete service configuration for the REST endpoint looks as follows.

<system.serviceModel>
 
<bindings>
 
<webHttpBinding>
  
<binding name="myRestfulBinding" />
 
</webHttpBinding>
 
</bindings>
 
<services>
 
<service behaviorConfiguration="VideoVSearchAggregator.VideoVisualSearchServiceBehavior"
 
             name="VideoVSearchAggregator.VideoVisualSearchService">
    <
endpoint address=""
                  
behaviorConfiguration="myRestfulBehaviour"
                  
binding="webHttpBinding
 
                  bindingConfiguration="myRestfulBinding
 
                 name="VisualVSearchAggregatorRestEndpoint" 
  
                contract="VideoVSearchAggregator.IVideoVisualSearchService" /> 
 
</service>
 
</services>
<behaviors
  <endpointBehaviors
   <behavior name="myRestfulBehaviour"
    <webHttp /> 
   </behavior
  </endpointBehaviors>
  <serviceBehaviors
   <behavior name="VideoVSearchAggregator.VideoVisualSearchServiceBehavior"
    <serviceMetadata httpGetEnabled="true" /> 
    <serviceDebug includeExceptionDetailInFaults="false" /> 
   </behavior>
  </serviceBehaviors
</behaviors
</system.serviceModel>

One thing to be aware of is the fact that your service itself opens HTTP connections via the SearchControllers so therefore if you deploy the service in an environment that uses a proxy server for outgoing requests you need to configure your environment respectively. For an IIS hosted WCF Service you can add the following elements to the Web.config.

<system.net>
 
<defaultProxy enabled="true">
  
<proxy bypassonlocal="true" proxyaddress="<proxy>" />
 
</defaultProxy>
 
</system.net>

Visual Search Configuration XML

In order to let people register the Visual Search service with their Internet Explorer it is necessary to create a XML search configuration that is published via a simple link in a hosting webpage. To create the configuration for a service it's best to follow the documentation on MSDN. My configuration looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Video Meta Search</ShortName>
<Description>Online videos from many sources at on glance</Description>
<Url type="text/html" template="http://(host)/VSearch/VideoVisualSearchService.svc/Search?query={searchTerms}"/>
<Url type="application/x-suggestions+xml" template="http://(host)/VSearch/VideoVisualSearchService.svc/Search?query={searchTerms}"/>
<Image height="16" width="16" type="image/icon">http://(host)/VSearch/images/VideoMetaSearch.ico</Image>
</OpenSearchDescription>

Webpage for adding the service to the IE search provider list

Well and finally we need to add a link to a webpage that lets the user register the search service. This can be achieved by calling the IE8 AddSearchProvider function. The function takes the URL to the XML configuration as a parameter. So in my case the call would look something like this:

<input type="button" value="Add Search Provider" onclick='window.external.AddSearchProvider("http://<host>/VSearch/XML/VideoVSearchAggregator.xml");'/>

After that you are ready to go! Hope you enjoyed the series and found some of the information helpful. The code for my project is attached to this post.

Reference:

As I started early with this series and lost momentum and therefore needed almost 3 months to finish there was the change to finish with similar projects earlier than me. So I have to give some Kudos to Guy Burstein, who already posted a blogpost covering almost the same topic - Congrats ;).

 

DeliciousBookmark this on Delicious Share  

The release of Internet Explorer 8 RC1 is just around the corner and fortunately there is a significant number of people and organization that want to release their own customized version of IE8. Luckily Microsoft publishes a tool that can let you easily customize IE8. The tool is called the Internet Explorer Administration Kit (IEAK) and its freely available. There are already quite a few blog posts about the tool itself so I don't want to rephrase all that if you are new to IEAK just go to the IEBlog and read the post by Jatinder Mann.

The current published version of the IEAK is the Beta 2 version that corresponds to the exact same version of IE8. So in order to prepare your customized IE8 package with RC1 bits for those that already have access to the IE8 builds > Beta2 there is no corresponding IEAK to those builds. However there is an easy workaround to use the Beta 2 IEAK with the newer bits. Just follow those 3 simple steps and you are done.

  1. Rename the IE8 RC1 setup executable to IE-REDIST.EXE
  2. Backup the original IE8 binaries used by the IEAK (usually in %ProgramFiles%\Microsoft IEAK8\Download\<Platform>\<Locale>\iebin\) and overwrite it with the newer file renamed in step 1. If you use IEAK for the first time the path and files may not exist so you need to start the IEAK wizard once and let it create the path and download the contents.
  3. Start and use the IEAK wizard as usual and create your customized IE8

Well I have to hurry up a bit as I initially planned to have this series finished even a while ago and now I'm even struggling to finish it until the end of the year. Anyway here is the next part and as promised this time I will focus on the search providers which feed the aggregator component with their content. As already mentioned since there are not many video portals that publish APIs I limited the search and implemented two providers which is however probably enough for demonstration purposes.

In order to live a bit of separation I first created a real simple interface which of course also describes the what the implementing search controllers can do. Since there is only one specific task the search controllers have to do is to fill a Section object which simply contains an array of objects. The interface itself is quite simple and contains only one method signature DoSearch(object obj) which takes an object as a parameter. Although in all cases the object that is filled is a Section object I needed to parameterize it with object because I use a threaded model for executing the searches with a ParameterizedThreadStart which unfortunately doesn't allow to pass on data to the thread procedure in a type-safe way. Alternatively I could have encapsulated the threaded calls to DoSearch() into a helper object which I would have initialized with the Section object to be filled by this thread however I didn't design the service in such a fine granular type-safe manner although it would have been relatively easy. If anybody follows the section and does his own implementation or variation the mentioned variant is described here. In any way here is the interface definition for the search controllers:

public interface ISearchController
{
   void DoSearch(object obj);
}

And here is the Section class which contains the results of the search:

[System.Serializable]
 public class Section
{
    [XmlElement]
    public object[] items { get; set; }
}

Now that I created the interface I was finally able to start with the implementation of the SearchControllers for the different providers.

  • YouTubeSearchController

    For the YouTube search I used the .Net Client Library which is a library that exposes the YouTube data API through a handy .Net object model which of course makes it really easy to perform searches and retrieve relevant content. Above that the API allows for some tweaking. For example I set the YouTubeQuery.NumberToRetrieve property to 5 as we don't need more because the number of results displayed by the VisualSearch window is limited and we want to display results from the other sources as well. So in order to create as little overhead as possible it is probably very sensible to limit the number of results.
    In order to be able to use the API you need a Google account need to register for a developer key and need to specify a name for your application in which you use the API.

    The search specific code in my YouTubeSearchController is outlined here:

    public void DoSearch(object youTubeSection)
    {
       try
       {
          ...
         
    this.youTubeSection = (Section)youTubeSection;
         
    YouTubeService service = new YouTubeService("<Your Application Name>");
         
    YouTubeQuery query = new YouTubeQuery(YouTubeQuery.DefaultVideoUri);
         
    query.OrderBy =
    "viewCount";
         
    query.Racy =
    "exclude";
         
    query.VQ = searchquery;
         
    query.NumberToRetrieve = 5;
         
    YouTubeFeed videoFeed = service.Query(query);
          this.youTubeSection.items = new object[videoFeed.Entries.Count + 1];
          Separator youtubeSeparator = new Separator();
          youtubeSeparator.title =
    "Videos On YouTube";
          this.youTubeSection.items[0] = youtubeSeparator;
          foreach (YouTubeEntry entry in videoFeed.Entries)
          {
            
    SectionItem secI = new SectionItem();
            
    if (!String.IsNullOrEmpty(entry.Title.Text))
            
    {
               
    secI.title = entry.Title.Text;
            
    }
            
    else
            
    {
               
    secI.title =
    "Title not available";
            
    }
            
            
    if (!String.IsNullOrEmpty(entry.Media.Description.Value))
            
    {
               
    if (entry.Media.Description.Value.Length > 50)
               
    {
                  
    secI.description = entry.Media.Description.Value.Substring(0, 50);
               
    }
                else
                {
                  
    secI.description = entry.Media.Description.Value;
               
    }
            
    }
            
    else
            
    {
               
    secI.description =
    "Description not available";
            
    }
            
    if (!String.IsNullOrEmpty(entry.AlternateUri.Content))
            
    {
               
    secI.url = entry.AlternateUri.Content;
            
    }
            
    else
            
    {
               
    secI.url =
    "Media URI not available";
            
    }
            
           
    ThumbnailCollection thumbs = entry.Media.Thumbnails;
           
    if (thumbs != null && thumbs.Count > 1)
           
    {
              
    Thumbnail thumb = new Thumbnail();
              
    thumb.source = thumbs[0].Url;
              
    thumb.alternateText = secI.title;
              
    thumb.height =
    "35";
              
    thumb.width =
    "35";
              
    secI.image = thumb;
            
    }
            
    else
            
    {
               
    secI.image =
    new Thumbnail();
            
    }
            
    this.youTubeSection.items[counter] = secI;
            
    ...
         
    }
         
    catch
         
    {
            
    throw new Exception();
         
    }
    }
     

  • Metacafe

    Metacafe also does provide an API however they offer a RSS API and return an XML feed for the search results. So the implementation for the MetaCafeSearchController looks a lot different.

    public void DoSearch(object metaCafeSection)
    {
       try
       {
          ...
          this.metaCafeSection = (Section)metaCafeSection;
          string uri = "http://www.metacafe.com/api/videos?vq=" + searchquery + "&max-results=5";
          Uri searchUri = new Uri(uri);
          WebRequest req = WebRequest.Create(searchUri);
          WebClient client = new WebClient();
          Stream resultData = client.OpenRead(searchUri);
          StreamReader sR = new StreamReader(resultData);
          XmlReader reader = XmlReader.Create(resultData);
          XmlDocument doc = new XmlDocument();
          doc.Load(reader);
          XmlNamespaceManager nSmgr = new XmlNamespaceManager(doc.NameTable);
          nSmgr.AddNamespace(
    "media", http://search.yahoo.com/mrss/);
          XmlNodeList itemList = doc.SelectNodes("/rss/channel/item");
          this.metaCafeSection.items = new object[itemList.Count + 1];
          Separator metacafeSeparator = new Separator();
          metacafeSeparator.title =
    "Videos on metacafe";
          this.metaCafeSection.items[0] = metacafeSeparator;
          foreach (XmlNode node in itemList)
          {
             SectionItem item = new SectionItem();
             XmlNodeList childNodes = node.ChildNodes;
             foreach (XmlNode child in childNodes)
             {
                if (child.Name.Equals("title"))
                {
                   if (!string.IsNullOrEmpty(child.InnerText))
                   {
                      item.title = child.InnerText;
                   }
                   else
                   {
                      item.title =
    "Title not available";
                   }
                }
                else if (child.Name.Equals("media:description"))
                {
                   if (!string.IsNullOrEmpty(child.InnerText))
                   {
                      if (child.InnerText.Length > 50)
                      {
                         item.description = child.InnerText.Substring(0, 50);
                      }
                      else
                      {
                         item.description = child.InnerText;
                      }
                   }
                   else
                   {
                      item.description =
    "Description not available";
                   }
                }
                else if (child.Name.Equals("link"))
                {
                   if (!string.IsNullOrEmpty(child.InnerText))
                   {
                      item.url = child.InnerText;
                   }
                   else
                   {
                      item.url =
    "Link not available";
                   }
                }
                else if (child.Name.Equals("media:thumbnail"))
                {
                   Thumbnail thumb = new Thumbnail();
                   if (!String.IsNullOrEmpty(child.Attributes[0].Value))
                   {
                      thumb.source = child.Attributes[0].Value;
                      thumb.alternateText = item.title;
                      thumb.height =
    "35";
                      thumb.width =
    "35";
                      item.image = thumb;
                   }
                   else
                   {
                      item.image =
    new Thumbnail();
                   }
                }
             }
     
            this
    .metaCafeSection.items[counter] = item;
            counter++;
            ...
        }
        catch
        {
           throw new ArgumentNullException("searchquery not set"
    );
        }
    }

So now with these two search implementations I get two Section objects which then again are aggregated into one single SearchItem object. Which then is serialized into the service response and feeds the VisualSearch client in Internet Explorer 8. This process was already mentioned in the last part.

So that's it for part four. The next part is probably going to be the last part and deals about the accompanying features of the service like threading, caching and configuration in a little bit more detail.

Reference:

DeliciousBookmark this on Delicious Share  

It's definitely about time to publish the promised third part of this series. This time I will cover the class model which I used to let the .Net XmlSerializer generate the necessary XML structure. I want to utilize almost the full breadth of the capabilities the Visual Search component is offering with respect of information display. So in this case the features are:

  • Categories or sections
  • Descriptions/Abstracts
  • Urls
  • Images

So the XML structure needs to look like the following:

<SearchSuggestion version="2.0" xmlns="http://opensearch.org/searchsuggest2">
    <Query></Query>
    <Section>
        <Separator title=""/>
        <Item>
            <Text></Text>
            <Description></Description>
            <Url></Url>
            <Image source="" alt="" width="" height=""/>
        </Item>
        <Item>
            ...
        </Item>
        ...
        <Separator title="Videos on metacafe"/>
        <Item>
            ...
        </Item>
        ...
    </Section>
</SearchSuggestion>

As I already mentioned I'm using the XmlSerializer in the .Net framework to serialize the XML drafted above. XmlSerializer serializes objects into XML and probably most of the sources (responses from the video services APIs) are XML you might want to ask the question why doing the indirection via a .net object model and not simply use XML transformation with an XML Stylesheet and send it straight over the wire using an XmlWriter. This is a valid question and the main reason why I didn't do it that way is because I started off with the YouTube service which gave me a pretty nice .Net based client API and others probably will follow. Another reason is that I wanted to use WCF which gives you more flexibility in targetting other clients as well and some quality of service features and knobs to fine tune the service.

So the object model looks like outlined in the following class diagram.

image

The properties in the classes are all annotated with the necessary XmlSerializer Attributes. So for example the code for the SearchItem class looks like the following:

[System.Serializable]
[XmlRootAttribute(Namespace = "
http://opensearch.org/searchsuggest2", ElementName="SearchSuggestion")]
public class SearchItem
{
        [XmlAttribute]
        public string version { get; set; }
        [XmlElement(ElementName = "Query")]
        public string query { get; set; }
       
        [XmlArrayItem(ElementName="Separator", Type=typeof(Separator))]
        [XmlArrayItem(ElementName="Item", Type=typeof(SectionItem))]
        public object[] Section { get; set; }
    }

The most important thing to mention here is that you need to define an array of type object in order to create the child elements of the section element as it needs to take two different types of objects (SectionItem and Separator). Another thing to mention is that the Section property is the aggregation of all results of the integrated video services and therefore I created a helper object (Section class). Every SearchController gets an instance of such a helper object to populate it with its own items and separator. In the end all helper objects of type Section are merged together to populate the SectionItem.Section property.

SearchItem sI = new SearchItem();

Section youTubeSection = new Section();

Section metacafeSection = new Section();

...

youTubeThread.Start(youTubeSection);

metacafeThread.Start(metacafeSection);

...

MergeSections();

...

youTubeSection.items.CopyTo(mergedSection, 0);
metacafeSection.items.CopyTo(mergedSection, youTubeSection.items.Length);

...

sI.Section = mergedSection;

The rest of the model is quite straight forward and I think it needs no further illustration. I will publish the complete code of the Video Visual Search with the last part of this series anyway.

The next part which hopefully doesn't take as long to publish as this one will deal with the Search Interface and the concrete implementations of it. Here's as usual a little teaser.

image

Reference:

DeliciousBookmark this on Delicious Share  

Welcome to part two of this series on how to implement a visual search service for IE8 using the Windows Communication Foundation (WCF) and other .Net technologies or libraries. The first part described the overall scenario of the service and today I want to go into a little more details with respect to the service itself.

With respect to the service there are some determining factors which need to be taken into account when creating the service contract interface which are:

  • The client is determined (The IE8 Visual Search Component) and is a black box for us
  • The schema of the messages accepted by the client is determined and is POX and is outlined here.
  • The client queries the service using plain parameterizes URLs via HTTP GET requests

This translates straight into the following attributes for our service.

  • We have to create a restful service that returns plain XML (no full blown SOAP Services)
  • Since the scenario implies some sort of contract-first design it is not since there is no metadata that describes the service and its operation and this actually implies that there is no contract (if you want to know a little bit more about contract-first I can recommend this article on theserverside.net)
  • We need full control over the serialization of the resulting XML

No with having this knowledge we can start to create the service.

After creating the service project in Visual Studio 2008 the first thing we do is to create the service interface which is quite simple in the sense that it only defines one single service operation at this time. My service operation is named "Search" (which is kickass creative) and accepts a single string parameter which is the search query.

So in the simplest case our service interface would look like this:

[ServiceContract]
public interface IVideoVisualSearchService
{
   [OperationContract]
   SearchItem
Search(string query);
}

However since we do have the attributes mentioned above we need to add some specific attribute.

  1. First is the [WebGet] attribute in order to make the service accessible via HTTP GET requests.
  2. We need to have full control over the structure of the resulting XML and therefore cannot use the DataContractSerializer which WCF uses by default to serialize the responses but need to specify the standard XMLSerializer in the .Net Framework. Therefore WCF introduces an XmlSerializerFormat attribute within the ServiceModel namespace which does exactly this.
  3. In addition we need to configure the service so that it exposes itself as a restful service. Therefore we could use a ServiceFactory in order to skip the sometimes cumbersome configuration steps however for the sake of transparency I create a manual configuration and then we need to add an endpoint with an webHttpBinding.

Having done all those modifications our service contract looks like this:

[ServiceContract]
[XmlSerializerFormat]
public interface IVideoVisualSearchService
{
   [OperationContract]
   [WebGet]
   [XmlSerializerFormat]
   SearchItem Search(string query);
}

and the minimal endpoint configuration in the looks like this:

<endpoint address="" 
             
behaviorConfiguration="myRestfulBehaviour"
             
binding="webHttpBinding"
             
contract="VideoVSearchAggregator.IVideoVisualSearchService" />

and the behavior configuration section is as well minimalistic and looks like this:

<endpointBehaviors>
   <
behavior name="myRestfulBehaviour">
      <
webHttp />
   </
behavior>
</
endpointBehaviors>

This also already marks the end of part II. In the next part I will give some more detailed information about the object model of the service which defines the content of the search results and how it is attributed to generate exactly the XML that the visual search component of IE8 expects. As a small teaser here is already the class class diagram of the object model to construct the response messages.

MessageClassDiagram

Reference:

DeliciousBookmark this on Delicious Share  

Beta 2 of Internet Explorer has been out for a while now and as you already know one of the new functionalities of Beta 2 is the visual search feature. Since there is a really extensive introduction about visual search and the steps on the IE8 side in this article on the Internet Explorer Team Blog I do not want to go into detail about this but rather tell you how to implement a service that is consumed by the Internet Explorer 8 Visual Search feature by means of a quite comprehensive example.

I chose a scenario which might be quite popular and that is video search. However since a user must explicitly register a search provider into his Internet Explorer unless you provide a customized instance using the Internet Explorer Administration Kit (IEAK). So in order to get one of the rare slots on the users search provider list I wanted to create some kind of meta search that aggregates search results from multiple sources. Another reason was that this enabled me to include and write about topics like threading and caching as well. In order to access the entries of the relevant video assets of the video sites I used their public APIs. Unfortunately it is not yet very common for those sites to offer public APIs to access their content especially in Germany I found none except for MyVideo.de however the application for an API key still remains unanswered. However at least I found two suitable APIs which are the YouTube and the metacafe API. The architecture of the service would allow to include further video provider at a later stage through a simple interface which could even be made configurable with the service evolving.

The requirements I defined for the service are:

  • Retrieval of video asset information from multiple sources

In order to provide the most possible value to the end user the visual search should aggregate multiple sources and provide a categorized visual search XML document to Internet Explorer.

  • Sources should be accessed in a non-sequential non-blocking manner

The Visual Search functionality is very performance sensitive because its sole purpose is to provide a preview of search results or suggestions while you type. And as we are usually typing quite fast the service ideally needs to respond as fast as we type. However from my experience many people as they get used to the value of the preview take some more time to type and skim through the results. However performance is one of the crucial non functional requirements of such a service. So I split the search operations on the different video sites up into different threads which signal the main thread when they are finished and the final result message can be assembled and send back to the browser. As this already has some great impact on performance I also defined a timeout for the main thread to wait for the search workers to finish which ensures quality of service to the search users.

  • Source specific search controllers which translate the incoming feed information into the service specific data model

Since all of the APIs are different in the form how they issue data each one has to be handled separately. For the services used this means that there are two search controllers which prepare the incoming data in order to transform it into the XML structure needed by the visual search feature. The effort depends on the structure of the underlying APIs. In my example the YouTube API is a bit easier to use since they already offer .Net client libraries for easy consumption. In the case of metacafe we need to care about the network operations and the parsing of the response message from the service a little bit more.

  • Caching functionality to reduce costly network access and time-consuming processing of the incoming responses

Again this is something that is very much related to performance but also needs some careful considerations because caching one one hand greatly boosts the services ability to respond to the service requests that fire against the service as you type however it also introduces the risk of sending outdated results to the browser. Therefore the invalidation time needs to be carefully defined. Most important to cache are also probably the one or two letter searches which are rarely of relevance but would require a full roundtrip of the search service whenever a search is started being typed.

  • Robust and stable hosting environment

A service like this which could easily be used by millions of users needs to be very robust and stable. Since this is already a challenge for the service application itself this is also true for the hosting environment. As I didn't want to care to much about this for my example I chose to host the WCF Service in Internet Information Service 7 as this is a production proven high scale hosting environment for web services.

So the high level architecture of the service looks like the following:

Search Service Architecture

Technologies used for the search service are as follows:

That's all for the introductory and overview part. In the next parts we dig a bit deeper into the into the architecture and the components.

And in order to give you a little preview of what you can expect here's a screenshot of the service in action.

IE8 Visual Search Sceenshot

DeliciousBookmark this on Delicious Share  
More Posts Next page »
 
Page view tracker