16.01.2013 Views

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

Microsoft Sharepoint Products and Technologies Resource Kit eBook

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 36: Building Applications for <strong>Microsoft</strong> Office SharePoint Portal Server 2003 993<br />

to query the search index. By default, results of this type of query are returned in<br />

order of relevance rank, descending from most relevant to least relevant. Booleans<br />

<strong>and</strong> wildcards are not currently supported out of the box with the default search<br />

constructor Web Part by SharePoint Portal Server 2003. The <strong>Microsoft</strong> SQL Syntax for<br />

Full-text Search (MSSQLFT) dialect can also be used to query the search index. Use an<br />

MSSQLFT query with the SQL SELECT response format to specify different sort orders.<br />

You will use the same set of controls for this sample application as you did for<br />

the first one. However, they will all perform different functions. The text box will be the<br />

string that you want to search for, the button will initiate the search, the tree view<br />

will contain our search results including a hyperlink to the resource, <strong>and</strong> the list<br />

view will just be used for providing feedback to the user.<br />

As with the AreaService Web service, you need to provide credentials to the<br />

search Web service. So, you will use the getUserCredentials function created earlier<br />

in this chapter to help with this functionality.<br />

Place the following code in the button1_Click function:<br />

private void button1_Click(object sender, System.EventArgs e)<br />

{<br />

//1. Setup a variable containing the XML required for querying<br />

// the Web service. Double quotes in the XML must be escaped<br />

// with a backslash. The SEARCHSTRING will be replaced later with<br />

// the actual string of keywords that the user wants<br />

// to search for.<br />

string queryString =<br />

"" +<br />

"" +<br />

"" +<br />

"" +<br />

"" +<br />

"urn:<strong>Microsoft</strong>.Search.Response.Document.Document" +<br />

"" +<br />

"" +<br />

"" +<br />

"" +<br />

"SEARCHSTRING" +<br />

"" +<br />

"" +<br />

"" +<br />

"1" +<br />

"9" +<br />

"" +<br />

"" +<br />

"";<br />

//2. Instantiate the proxy to the SearchWebService Web Service<br />

SearchWebService.QueryService queryWS =<br />

new SearchWebService.QueryService();<br />

//3. Set credentials for authentication to the Web service<br />

queryWS.Credentials = getUserCredentials();

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!