设置代理。

设置代理。

访问http://www.webservicex.net/globalweather.asmx时vs.net的生成的代理类的代码:
其中
System.Net.WebProxy myProxy
=new System.Net.WebProxy("192.1.1.1",8080);
this.Proxy=myProxy;
就是设置代理服务器的代码
 [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.1.1.1",8080);
   this.Proxy=myProxy;
  }
       
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.webserviceX.NET/GetWeather", RequestNamespace="http://www.webserviceX.NET", ResponseNamespace="http://www.webserviceX.NET", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public string GetWeather(string CityName, string CountryName) {
            object[] results = this.Invoke("GetWeather", new object[] {
                        CityName,
                        CountryName});
            return ((string)(results[0]));
        }
       
        /// <remarks/>
        public System.IAsyncResult BeginGetWeather(string CityName, string CountryName, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("GetWeather", new object[] {
                        CityName,
                        CountryName}, callback, asyncState);
        }
       
        /// <remarks/>
        public string EndGetWeather(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((string)(results[0]));
        }
       
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://www.webserviceX.NET/GetCitiesByCountry", RequestNamespace="http://www.webserviceX.NET", ResponseNamespace="http://www.webserviceX.NET", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        public string GetCitiesByCountry(string CountryName) {
          
   object[] results = this.Invoke("GetCitiesByCountry", new object[] {
                        CountryName});
   
            return ((string)(results[0]));
        }
       
        /// <remarks/>
        public System.IAsyncResult BeginGetCitiesByCountry(string CountryName, System.AsyncCallback callback, object asyncState) {
            return this.BeginInvoke("GetCitiesByCountry", new object[] {
                        CountryName}, callback, asyncState);
        }
       
        /// <remarks/>
        public string EndGetCitiesByCountry(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((string)(results[0]));
        }
    }
}

 

posted on 2004-10-14 16:34  LEE  阅读(376)  评论(0编辑  收藏  举报

导航