15.11.11

Search foundation client object model

 

If you don’t understand, it's not for you

 

using (QueryWebServiceProxy.QueryService queryService = new QueryWebServiceProxy.QueryService())
                {

                    string url = @”http://moss/_vti_bin/spsearch.asmx”;

                    queryService.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
                    queryService.PreAuthenticate = true;
                    queryService.Credentials = new System.Net.NetworkCredential("user", "pass", "dom");
                    queryService.Url = url;

                    message.Text = queryService.Status();

                    string qXMLString = "<QueryPacket xmlns='urn:Microsoft.Search.SpQuery'>" +
                      "<Query>" +
                     "<Context><QueryText language=\"en-US\" type=\"MSSQLFT\">SELECT Title, Path, Description, Write, Rank, Size FROM Scope() WHERE FREETEXT(DEFAULTPROPERTIES,'" +
                    TextBox1.Text + "') ORDER BY Rank --</QueryText></Context></Query></QueryPacket>";

                    XmlDocument xml = new XmlDocument();

                    object obj = queryService.QueryEx(qXMLString);

                    if (obj != null)
                    {
                        DataSet dtqueryResults = (DataSet)obj;

                        GridView1.DataSource = dtqueryResults.Tables[0];
                        GridView1.DataBind();
                    }


                    xml.LoadXml(queryService.Query(qXMLString));

                    resultsLabel.Text = xml.OuterXml;

               }

            }
            catch (Exception ex)
            {
                resultsLabel.Text = ex.Message;
            }

No comments:

Post a Comment