Solved

c# google search

Posted on 2011-02-15
3
741 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

760 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

24 Experts available now in Live!

Get 1:1 Help Now