0

我在学习 ASP.Net 中的 Web 服务时遇到了一个疑问。我开发了一个应用程序,借助www.webservicex提供的“ GlobalWeather ”Web 服务,它可以
为我们提供印度各个城市(“ GetWeather ”)的当前天气信息.net _ 我曾尝试使用网络服务“ http://wsf.cdyne.com/WeatherWS/Weather.asmx?op=GetCityWeatherByZIP ”...

似乎将www.webservicex.netwsf.cdyne.com/WeatherWS/Weather.asmx n 提供的 xml 值获取到 asp.net 代码中两者都不同......为什么会这样????

这就是我在单个应用程序中实现两者的方式。它的工作但是,谁能告诉我为什么我应该以不同的方式实现它....

public partial class _Default : System.Web.UI.Page

{

globweather.GlobalWeather obj2 = new globweather.GlobalWeather(); 
wservice.Weather obj1 = new wservice.Weather();

protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button1_Click(object sender, EventArgs e)
{

    string zip = TextBox2.Text;
    //Response.Write(obj2.GetWeather("New Delhi", "India"));
    string s = obj2.GetWeather("New Delhi", "India");

   // load return string value to dataset

    System.IO.StringReader sr = new System.IO.StringReader(s);
    System.Data.DataSet ds = new System.Data.DataSet(); 
    ds.ReadXml(sr);

   // loop thru value in dataset

   foreach (System.Data.DataRow row in ds.Tables[0].Rows) 
   {

  // for (int i = 0; i < row.ItemArray.Length; i++ ) 
  //{

  // Response.Write("Col " + i.ToString() + " value = " + row.ItemArray[i] + "<br/>"); 
  //} 
       string ddd=row.ItemArray[2].ToString();
       TextBox1.Text="wind speed:- "+ddd.Substring(29,5);
   }

    Label1.Text = obj1.GetCityWeatherByZIP(zip).Temperature;
    Label2.Text = obj1.GetCityWeatherByZIP(zip).City;
    int id=Convert.ToInt32(obj1.GetCityWeatherByZIP(zip).WeatherID);
    if(id==1) 
      { Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/thunderstorms.gif";}
    if(id==2)             
      { Image1.ImageUrl="http://ws.cdyne.com/WeatherWS/Images/partlycloudy.gif";}
    if(id==3) 
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/mostlycloudy.gif";}
     if(id==4)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/sunny.gif";}
    if(id==5)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/rain.gif";}
    if(id==6)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/showers.gif";}
    if(id==7) 
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/haze.gif";}
    if(id==9)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/mostlycloudy.gif";}
    if(id==10)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/partlycloudy.gif";}
    if(id==11)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/sunny.gif";}
    if(id==12)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/partlycloudy.gif";}
    if(id==14)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/mostlycloudy.gif";}
    if(id==15)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/na.gif";}
    if(id==17)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/drizzle.gif";}
    if(id==18) 
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/fog.gif";}
    if(id==20)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/blowingsnow.gif";}
    if(id==21)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/blowingsnow.gif";}
    if(id==26)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/blowingsnow.gif";}
    if(id==27)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/snow.gif";}
    if(id==28)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/rain.gif";}
    if(id==29)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/blowingsnow.gif";}
    if(id==32)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/rain.gif";}
    if(id==33)
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/rain.gif";}
    if(id==34) 
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/na.gif";}
    if(id==35)   
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/blowingsnow.gif";}
    if(id==36)  
       {Image1.ImageUrl= "http://ws.cdyne.com/WeatherWS/Images/na.gif";}
    if (id == 37)
       { Image1.ImageUrl = "http://ws.cdyne.com/WeatherWS/Images/partlycloudy.gif"; }

   }  
}
4

0 回答 0