Creating Search Queries Programmatically by using the Search Web Service in SharePoint Server 2007
Summary: Learn how to programmatically create search queries by using the Search Web service in Microsoft Office SharePoint Server 2007.
Applies to: Microsoft Office SharePoint Server 2007
Patrick Tisseghem, U2U
Microsoft Office SharePoint Server 2007 includes a Web service named search.asmx that allows a remote client to execute a search query.
Developers working in Microsoft Visual Studio 2005 add a Web reference to the project that points to the search.asmx Web service, located in the
Request Query Packet
The call to either the Query or QueryEx Web method is simple. One parameter is a blob of XML containing all of the information required for the search service to execute the query. The request query packet used for a keyword query follows.
Executing a Query
You execute the query by first creating an instance of the proxy class. Next, you have to perform the authentication. You can pass the credentials of the currently logged-on user (as shown in the code example), or you can create an instance of the NetworkCredential class. For the latter option, you must pass the credential information to the constructor. The request query packet containing the keyword query is passed simply as the only parameter with both the Query and QueryEx methods. The Query method returns the search results in raw XML format. The QueryEx method returns the search results as a serialized DataSet object. The proxy class makes the DataSet object directly available so that you can bind it to one of your user interface (UI) controls.
The Search Web Service exposed by Microsoft Office SharePoint Server 2007 allows for remote execution of a search query. The query must be encapsulated in a request packet and can either be formulated with the keyword syntax or the full-text SQL syntax.
Two methods allow for the execution of the query:
Length: 04:36 | Size: 2.63 MB | Type: WMV file