Set proxy.
Access the proxy class generated by vs.netat http://www.webservicex.net/globalweather.asmx. Code :
Where
System. net. WebProxy myproxy
= New system. net. WebProxy ("Fig", 8080 );
This. Proxy = myproxy;
Is to set the proxy server code
[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 ";
// Specify the Proxy Server
System. net. WebProxy myproxy
= New system. net. WebProxy ("Fig", 8080 );
This. Proxy = myproxy;
}
/// <Remarks/>
[System. web. services. protocols. soapdocumentmethodattrispace ("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. soapdocumentmethodattrispace ("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]);
}
}
}