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:
This translates straight into the following attributes for our service.
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.
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.
Reference: