使用Google(转)

Posted on 2005-08-29 10:21  爱克软件  阅读(404)  评论(0)    收藏  举报

我照着下面的地址做的实验
http://www.zahui.com/html/14/31577.htm

但是目前程序报下列错误:
“下列连接已经关闭,无法解析远端名称“

我添加的web引用地址是
http://api.google.com/GoogleSearch.wsdl
命名为googletest


我的程序代码如下,

googletest.GoogleSearchService webtest=new googletest.GoogleSearchService();
googletest.GoogleSearchResult webResult = null;
try
{
webResult = webtest.doGoogleSearch("QwYw+n1QFHLfp38IFx0xtoRoFIpZzSyG","helloworld",0, 10, false, "", false, "", "", "");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
//--绑定结果(略)--

我在.cs文件中输入googletest,然后输入“.”后面的“GoogleSearchService“可以自动带出来的,
感觉webservice已经添加成功了啊,?但是为什么会报错呢??

程序中 “QwYw+n1QFHLfp38IFx0xtoRoFIpZzSyG“  是我注册后google发给我的 license key
        "helloworld"    是我要搜索的内容。


请问大家,我还有什么地方没有设置吗????????在线等,先谢谢了,帮顶有分分啊~~~!


呵呵,问题自己解决了,原因是我通过代理服务器访问WEBSERVICE而没有设置代理服务。
这样我访问http://api.google.com/GoogleSearch.wsdl时vs.net的生成的代理类的代码:
加入如下代码就OK了~~!~哈

  [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="GlobalWeatherSoap", Namespace="http://www.webserviceX.NET")]
    public class GlobalWeather : System.Web.Services.Protocols.SoapHttpClientProtocol {
       
        /// <remarks/>
        public GlobalWeather() {
            this.Url = "http://www.webservicex.net/globalweather.asmx";


//-----------指定代理服务器--(这里既是新增代码)-----------------
System.Net.WebProxy myProxy
=new System.Net.WebProxy("192.*.*.*",8080);   //“192.*.*.*“为代理服务器的IP地址
this.Proxy=myProxy;
//-------------------------------------------------------------------------
}

博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3