設定代理。

來源:互聯網
上載者:User

設定代理。

訪問http://www.webservicex.net/globalweather.asmx時vs.net的產生的代理類的代碼:
其中
System.Net.WebProxy myProxy
=new System.Net.WebProxy("192.1.1.1",8080);
this.Proxy=myProxy;
就是設定Proxy 伺服器的代碼
 [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";
   //指定Proxy 伺服器
   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]));
        }
    }
}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.