<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.dotnetmafia.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>How to: Query Search using the Web Service</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx</link><description>According to FeedBurner , my posts on querying Enterprise Search with the FullTextSqlQuery and KeywordQuery classes have been some of the most popular. So I thought, I would continue on these posts and explain how to do it using the web service. The SDK</description><dc:language>en</dc:language><generator>CommunityServer 2007.1 (Build: 20917.1142)</generator><item><title>re: How to: Query Search using the Web Service</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#3831</link><pubDate>Fri, 30 Jul 2010 09:35:24 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:3831</guid><dc:creator>Stefam</dc:creator><description>&lt;p&gt;Hello &amp;nbsp;i use SP Foundation 2010. &lt;/p&gt;
&lt;p&gt;I have a problem with the search Webservice.&lt;/p&gt;
&lt;p&gt;I become no results with this sourcecode&lt;/p&gt;
&lt;p&gt;Where is the error? &lt;/p&gt;
&lt;p&gt;Can you help me? &lt;/p&gt;
&lt;p&gt;thx!&lt;/p&gt;
&lt;p&gt; Suche123.QueryService test = new Suche123.QueryService();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;test.Credentials = CredentialCache.DefaultCredentials.GetCredential(new Uri(test.Url), &amp;quot;NTLM&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;test.PreAuthenticate = true;&lt;/p&gt;
&lt;p&gt;				if (!test.Status().Equals(&amp;quot;ONLINE&amp;quot;)) {				&lt;/p&gt;
&lt;p&gt;					return;&lt;/p&gt;
&lt;p&gt;				}&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;StringBuilder queryXml = new StringBuilder();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;QueryPacket xmlns=\&amp;quot;urn:Microsoft.Search.Query\&amp;quot; Revision=\&amp;quot;1000\&amp;quot;&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;Query domain=\&amp;quot;QDomain\&amp;quot;&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;SupportedFormats&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;Format&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;urn:Microsoft.Search.Response.Document.Document&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;/Format&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;/SupportedFormats&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;Range&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;Count&amp;gt;50&amp;lt;/Count&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;/Range&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;Context&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;QueryText language=\&amp;quot;en-US\&amp;quot; type=\&amp;quot;STRING\&amp;quot;&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;/QueryText&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;/Context&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;/Query&amp;gt;&amp;quot;);&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;queryXml.Append(&amp;quot;&amp;lt;/QueryPacket&amp;gt;&amp;quot;); &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;string resultXml2 = &amp;quot;&amp;quot;;&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;var queryResults = new System.Data.DataSet();&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; resultXml2 = test.Query(queryXml.ToString());&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; queryResults = test.QueryEx(queryXml.ToString());&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DataGrid1.DataSource = queryResults.Tables[0];&lt;/p&gt;
&lt;p&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;DataGrid1.DataBind();&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=3831" width="1" height="1"&gt;</description></item><item><title>re: How to: Query Search using the Web Service</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#3749</link><pubDate>Tue, 20 Jul 2010 14:24:20 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:3749</guid><dc:creator>CoreyRoth</dc:creator><description>&lt;p&gt;@Ian Enterprise Search does not like single quotes. &amp;nbsp;Replace with a quote (&amp;quot;) and you should be good. &amp;nbsp;Since you're dealing with a string you will probably have to use \&amp;quot; to delimit it properly.&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=3749" width="1" height="1"&gt;</description></item><item><title>re: How to: Query Search using the Web Service</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#3746</link><pubDate>Tue, 20 Jul 2010 09:17:40 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:3746</guid><dc:creator>Ian P</dc:creator><description>&lt;p&gt;How would you specify specific doc types from the query? &amp;nbsp;E.g: &lt;/p&gt;
&lt;p&gt;&amp;lt;QueryText language=&amp;#39;en-US&amp;#39; type=&amp;#39;STRING&amp;#39;&amp;gt;sharepoint filetype:&amp;#39;pdf&amp;#39;&amp;lt;/QueryText&amp;gt;&lt;/p&gt;
&lt;p&gt;This does not work!&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=3746" width="1" height="1"&gt;</description></item><item><title>Sharepoint Web Servisleri - Search/Query Web Servisi | YAZILIM KUL??B??</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#898</link><pubDate>Wed, 06 May 2009 06:29:45 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:898</guid><dc:creator>Sharepoint Web Servisleri - Search/Query Web Servisi | YAZILIM KUL??B??</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Sharepoint Web Servisleri - Search/Query Web Servisi | YAZILIM KUL??B??&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=898" width="1" height="1"&gt;</description></item><item><title>re: How to: Query Search using the Web Service</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#774</link><pubDate>Tue, 11 Nov 2008 19:36:38 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:774</guid><dc:creator>CoreyRoth</dc:creator><description>&lt;p&gt;I am afraid I don't have any experience calling a web service from BuddyScript. &amp;nbsp;Calling the MOSS web service is just like calling any other web service when passing credentials. &amp;nbsp;I would look and see if there is a way to pass the credentials when calling a web service. &amp;nbsp;You can't pass them in via the XML string though.&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=774" width="1" height="1"&gt;</description></item><item><title>re: How to: Query Search using the Web Service</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#772</link><pubDate>Tue, 11 Nov 2008 10:09:35 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:772</guid><dc:creator>andremt</dc:creator><description>&lt;p&gt;yes, but i am trying acess from buddyscript (building an agent), and there is not possible have this lines. So i need to put that credentials in the string. is possible?&lt;/p&gt;
&lt;p&gt;Thanks for reply&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=772" width="1" height="1"&gt;</description></item><item><title>re: How to: Query Search using the Web Service</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#771</link><pubDate>Mon, 10 Nov 2008 16:52:21 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:771</guid><dc:creator>CoreyRoth</dc:creator><description>&lt;p&gt;You have to provide credentials to the web service. &amp;nbsp;This line uses the credentials of the current account. &amp;nbsp;queryService.Credentials = System.Net.CredentialCache.DefaultCredentials;&lt;/p&gt;
&lt;p&gt;You can also specify your own credentials if necessary.&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=771" width="1" height="1"&gt;</description></item><item><title>re: How to: Query Search using the Web Service</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#767</link><pubDate>Wed, 05 Nov 2008 10:01:30 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:767</guid><dc:creator>andremt</dc:creator><description>&lt;p&gt;Hi. i have a doubt about this post&lt;/p&gt;
&lt;p&gt;You pass xml to a string, and my question is how i can put credentials in that string?&lt;/p&gt;
&lt;p&gt;Because without the credentials, with that string i get error 401.&lt;/p&gt;
&lt;p&gt;I have somehow attach the credentials&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
&lt;p&gt;Andr&amp;#233;&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=767" width="1" height="1"&gt;</description></item><item><title>Bookmarking the web - w29/2008 - double density design</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#641</link><pubDate>Tue, 22 Jul 2008 06:08:35 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:641</guid><dc:creator>Bookmarking the web - w29/2008 - double density design</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Bookmarking the web - w29/2008 - double density design&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=641" width="1" height="1"&gt;</description></item><item><title>Links (7/17/2008) &amp;laquo; Steve Pietrek - Everything SharePoint</title><link>http://www.dotnetmafia.com/blogs/dotnettipoftheday/archive/2008/07/17/how-to-query-search-using-the-web-service.aspx#637</link><pubDate>Fri, 18 Jul 2008 01:42:53 GMT</pubDate><guid isPermaLink="false">ceb7fe2a-c56b-4d85-99e6-8dd548580538:637</guid><dc:creator>Links (7/17/2008) « Steve Pietrek - Everything SharePoint</dc:creator><description>&lt;p&gt;Pingback from &amp;nbsp;Links (7/17/2008) &amp;amp;laquo; Steve Pietrek - Everything SharePoint&lt;/p&gt;
&lt;img src="http://www.dotnetmafia.com/aggbug.aspx?PostID=637" width="1" height="1"&gt;</description></item></channel></rss>