Click here to Skip to main content
15,615,280 members
Articles / Programming Languages / PHP
Posted 28 Feb 2012

Tagged as


9 bookmarked

Windows Federated Search using OpenSearch for PHP

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
28 Mar 2013GPL37 min read
How to build an OpenSearch data source that can be searched using Windows 7 Federated Search functionality. Following the best practices, you can enable rich integration of your remote data sources with Windows 7 Explorer without having to write any client-side code.


Windows 7 introduces support for search federation to remote data stores using OpenSearch technologies that enable users to access and interact with their remote data from within Windows Explorer.

This document describes how to build a web-based data source that can be searched using Windows federated search. Following the best practices described here, you can enable rich integration of your remote data sources with Windows Explorer without having to write or deploy any Windows client-side code.

Search Engine Autodiscovery

Autodiscovery is a means for automatically finding machine-processable resources associated with a particular web page. The discovery can be automated because the resource is linked to in a well-defined way.

At time I had initially wrote this article, all prominant browsers (IE8, Chrome, and Firefox) openly supported search engine autodiscovery of those endpoints that OpenSearch compliant. However, since then only Firefox still easy provides the ability to add an OpenSearch provider; with Chrome you have to go through their Settings / Manager Search, and IE9 dropped it completely.

Here are some great articles about setting up specific browsers for Search Engine Autodiscovery:

For the best experience of OpenSearch, choose Firefox because it gives you the easiest possibility to add an OpenSearch engine to your browser.

Deployed Example:

What is Windows Federated Search?

Windows Federated Search enables users to search remote data sources from within Windows Explorer. Remote data sources make themselves searchable with a simple web front end that exposes their search capabilities.

The benefit of integrating your data source with Windows Explorer is that users can get at all of their information by using the already familiar Windows Explorer user interface. Your users will be able to see files from your remote data source just as they would local files, with the right application icons and context menus.

Complete explanation if found here on Microsoft site: Federated Search in Windows

Windows Federated Search Sample Setup

The OpenSearch sample demonstrates how a PHP based web-site can expose its search via an OpenSearch endpoint and optionally provide a search filter within Windows Explorer to search the site. For the sake of simplicity, in this sample the OpenSearch endpoint on the PHP web-site simply uses the Yahoo Stock Quote service to get results. In a real-world scenario, the Search endpoint would likely invoke the web-site's internal search functionality.

There are five simple steps to getting Windows Federated Search Web Service endpoint demo to be accessible by Windows 7 Explorer's Federated Search functionality as shown in the figure below.

  1. Install Windows Federated Search Demo Endpoint folder WindowsFederatedSearch4PHP into a web service.
  2. For data source to access information beyond a firewall, then it may be necessary to modify proxy settings within WindowsFederatedSearch_UserConfig.class.php.
  3. Test RSS feed from Windows Federated Search Endpoint within a browser.
  4. Modify with URL path in Windows Federated Search Description document WindowsFederatedSearch4PHP.osdx.
  5. Deploy OSD document WindowsFederatedSearch4PHP.osdx to create a Search Connector within a client's Windows 7 Explorer


Step 1 - Create Windows Federated Search Web Service Endpoint - Install Demo Folder

Place folder WindowsFederatedSearch4PHP with all of its contents into your website.

By default, all required configuration to get this demo to operate has placed folder WindowsFederatedSearch4PHP into the localhost's root directory, port 80, and no proxy is required to gain outside the firewall access; in other words the Windows Federated Search endpoint is accessible from browser at URL address of:


Step 2 - Modify cURL Proxy Settings for Window Federated Search Web Service Endpoint

WindowsFederatedSearch_DataSource.class.php is an example data source used by this sample Window Federated Search Web Service Endpoint. This data source estabilishes a connection to an external stock quote provider, Yahoo Stock, using PHP cURL.

If a proxy is necessary for estabilishing an Internet connection through a firewall, then it may be necessary to modify proxy information within PHP file WindowsFederatedSearch_UserConfig.class.php.

If a proxy is not required to access a site, then this step can be skipped.

PHP – WindowsFederatedSearch_UserConfig.class.php

Modify Search Name and Server settings for WindowsFederatedSearch_DataSource Endpoint

class UserConfigConstants
    const OPEN_SEARCH_SHORT_NAME            = 'Windows Federated Search 4 PHP';
    const OPEN_SEARCH_DESCRIPTION           = 'Windows Federated Search for PHP Developers Demo';
    const SERVER_NAME                       = 'localhost';
    const SERVER_PORT                       = 80;
    const SERVER_ENDPOINT_PROXY             = 'itgproxy';   /* CURLOPT_PROXY */
    const SERVER_ENDPOINT_PROXY_PORT        = '80';         /* CURLOPT_PROXYPORT */

Step 3 - Test Windows Federated Search Web Service Endpoint with Browser

As mentioned, Windows Federated Search requires an RSS-2 feed from OpenSearch Web service. The easiest way to verify that your OpenSearch Web service is operational is to perform a search request to its endpoint from a browser.

The easiest solution provided by demo is to open the Internet Explorer 8 browser to the root of WindowsFederatedSearch4PHP's URL path.


This will provide to the Internet Explorer 8 browser a OpenSearch Description (OSD) document, and will be visible within the search box at the upper right corner of this browser.

For example, if the WindowsFederatedSearch4PHP is installed on localhost:80, then the following link should work in acquiring a OpenSearch Description document directly to the Internet Explorer 8 browser:



Enter within this search box with "Windows Federated Search 4 PHP" selected these stock symbols MSFT SY BA, and everything is correctly setup the browser should list the most current stock quotes.


What is occurring is that "Windows Federated Search 4 PHP" selection is a reference to an OpenSearch endpoint URL, and the browser builds a query based upon the user's search terms provide. For this demo, the following URL path performs a search request of these stock quotes: MSFT SY BA

The default OpenSearch description will be using format=html and source=IE-SearchBox, as is presented within the image previously:


For Windows Federated Search, the OpenSearch result needs to be format=rss:


For example, if the WindowsFederatedSearch4PHP is installed on localhost:80, then the following link should work:


If RSS feed is operational, then the following feed should be appear within your browser:


Internet Explorer – Turn On Feed Read

If you are using Internet Explorer (IE) and you see the following raw RSS XML feed, this is then you will need to turn on within this browser the the ability to read this feed.


In IE browser's menu bar, select Tools > Internet Options, then Content tab. Within Content tab in its Feeds and Web Slices section, select Settings button.


Within Feed and Web Slice Settings panel in its Advanced section, check box next to Turn on feed reading view. Then re-open browser. It should render a styled RSS view as presented previously.


Step 4 - Modify OpenSearch Description Document - WindowsFederatedSearch4PHP.osdx

This step sets up demo's OpenSearch Description document WindowsFederatedSearch4PHP.osdx which is used to estabilish a Search Connector within Windows 7 Explorer.

If this setup location for WindowsFederatedSearch4PHP is at URL http://localhost/WindowsFederatedSearch4PHP/, then this step can be skipped.

Three modifications are required and all modifications should have the same path value. By default, all three of the following have a value of http://localhost/WindowsFederatedSearch4PHP/:

  • URL type="application/rss+xml"
  • URL type="text/html"
  • Image
XML – WindowsFederatedSearch4PHP.osdx

Modify paths to OpenSearch Endpoints

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="" >
  <Description>Windows Federated Search For PHP Developers</Description> 
  <!-- BEGIN: templates for Search Provider Endpoints and Image. -->
  <!-- TODO: Replace http://localhost/WindowsFederatedSearch4PHP/ with Search Providers URL. -->
    <Url type="application/rss+xml" template="http://localhost/WindowsFederatedSearch4PHP/search.php?query={searchTerms}&amp;format=rss&amp;src=ms-ose&amp;start={startIndex}&amp;cnt={count}"/>
    <Url type="text/html" template="http://localhost/WindowsFederatedSearch4PHP/search.php?query={searchTerms}"/>
    <Image height="16" width="16" type="image/x-icon">http://localhost/WindowsFederatedSearch4PHP/favicon.ico</Image>
  <!-- END: templates for Search Provider Endpoints and Image. -->

Step 5 - Install Windows Federated Search Description document

Within a Windows 7 client, double-click your Windows Federated Search Description (OSD) document (WindowsFederatedSearch4PHP.osdx) which will perform "Create Search Connector". This will add a new connection to your Windows Federated Search Web Service endpoint within "Search" box of client's Windows Explore.


Step 6 - Perform Search within Windows 7 Explorer

The following figure shows the Windows Federated Search results based upon a stock symbols search request within Windows 7 Explorer. Search box contains these symbols:


Helpful Tips

Internet Explorer Browsers that support OpenSearch

OpenSearch was introduced into the IE Search Box in IE-7 browser and was carried over into IE-8 browser. However, to much dismay and disgruntlement, OpenSearch functionality was dropped from IE-9.

Debugging OpenSearch Description OSDX

If at the start when providing OpenSearch site to be selected by IE Search Box to an IE-8 browser, and it is not recognized; then gather the generated OSDX by downloading the description.php via the browser:


The saved description.php file will contain the generated OSDX. Next, validate that the OpenSearch XML description is complete and without extra characters. For example, this is a valid OSDX content using by another OpenSearch site generated by its description.php:
  <ShortName>Windows Federated Search 4 PHP</ShortName>
  <Description>Windows Federated Search for PHP Developers Demo</Description>
  <Url type="text/html" template="{searchTerms}&amp;format=html&amp;src={referrer:source?}&amp;start={startIndex}&amp;cnt={count}" />
  <Image height="16" width="16"></Image>


  • 2012 February 29 -- Updated
  • 2012 February 29 -- Add new section Helpful Tips


This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)

Written By
Software Developer (Senior)
United States United States
I enjoy and take seriously the craft of programming, and I improve upon my skills daily. Start day: coffee is always a good idea!

Comments and Discussions

QuestionFederated search for CIFS Pin
AKG8-Mar-12 22:41
AKG8-Mar-12 22:41 
AnswerRe: Federated search for CIFS Pin
jeff00seattle18-Mar-12 8:45
jeff00seattle18-Mar-12 8:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.