Solved

c# google search

Posted on 2011-02-15
3
743 Views
Last Modified: 2012-06-21
I get this code in internet and it show
I have this file wsdl.exe on C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin



Error      1      The type or namespace name 'GoogleSearchService' could not be found (are you missing a using directive or an assembly reference?)      C:\Users\¿¿¿7\AppData\Local\Temporary Projects\googlesearch\Program.cs      22      9      googlesearch



// googly.cs
// A Google Web API C# console application.
// Usage: googly.exe <query>
// Copyright (c) 2002, Chris Sells.
// No warranties extended. Use at your own risk.
using System;
class Googly
{
    static void Main(string[] args)
    {
        // Your Google API developer's key.
        string googleKey = "insert key here";
        // Take the query from the command line.
        if (args.Length != 1)
        {
            Console.WriteLine("Usage: google.exe <query>");
            return;
        }
        string query = args[0];
        // Create a Google SOAP client proxy, generated by:
        // c:\> wsdl.exe http://api.google.com/GoogleSearch.wsdl
        GoogleSearchService googleSearch = new GoogleSearchService();
        // Query Google.
        GoogleSearchResult results = googleSearch.doGoogleSearch(googleKey,
    query, 0, 10, false, "", false, "", "latin1", "latin1");
        // No results?
        if (results.resultElements == null) return;
        // Loop through results.
        foreach (ResultElement result in results.resultElements)
        {
            Console.WriteLine();
            Console.WriteLine(result.title);
            Console.WriteLine(result.URL);
            Console.WriteLine(result.snippet);
            Console.WriteLine();
        }
    }
}

Open in new window

0
Comment
Question by:teera
3 Comments
 
LVL 16

Accepted Solution

by:
Kalpesh Chhatrala earned 167 total points
ID: 34904387
0
 
LVL 8

Assisted Solution

by:guvera
guvera earned 166 total points
ID: 34904567
Hi,

There might be two possible causes for this error.

  1. May be you have not created your "net" folder" as web application.
  2. May be you have named the namespace wrong while creating the assembly.

Also please check the below links.

 http://www.sitepoint.com/forums/showthread.php?t=388702

Hope it may helpful to you.

Regards
Guvera
0
 
LVL 15

Assisted Solution

by:Russell_Venable
Russell_Venable earned 167 total points
ID: 34913043
knowing that Googles WSDL interface code is obsolete and how Google has switched to using JSON and AJAX requests as they allow your searches to be quicker. Checking the SOAP proxy address to see if google is still implementing it, you would notice that manually browsing to the address show's.
 Google 404So in otherwords you need to use the current API given by Google to access there functionality.
You will need to sign-up for a API key if you dont already have one:Google API Key Registration

After gaining the key you can download the Current API for clients from here:
Google Data Protocol  - Client Libraries

Just add the required userspace:
using Google.GData.Client;

Open in new window

and then then convert your code from there or
 Best solution I can give you is using Gapi.NET - .NET (C#) wrapper for Google AJAX API as this is the method currently implemented to use googles search results and this wrapper is the solution for using those JSON/AJAX posts.


Reference:
Google SOAP Search API (No Longer Available)
This is another example but using googles query and regex to filter content.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now