我在同一单元第二次调用getWeatherbyCityName,获取不同城市天气,出错:No WSDL or URL property was set in the THTTPRIO component. 第一次调用没问题,那位处理过这种问题?

解决方案 »

  1.   

    2个 Button2Click 代码类似
    procedure TiWeather.Button2Click(Sender: TObject);
    var  a:shortint;
      myWp: WeatherWebServiceSoap;
      my: ArrayOfString;
      I: Integer;
      CityName:string;
      t: string;
        t2: string;
      ii:integer;  b: integer;begin
        HTTPRIO2.HTTPWebNode.UseUTF8InHeader:= true;
        myWp:= HTTPRIO2 as WeatherWebServiceSoap;
        CityName:='北京';
        my:= mywp.getWeatherbyCityName(cityname);
        Label6.Caption:=''+ my[5] ;    t := ExtractFilePath(Application.ExeName) +'weather\a_'+ my[8];    if FileExists(t) then
        Image3.Picture.LoadFromFile(t)
      //  Image1.Picture.LoadFromFile('D:\天气预报\weather\3.gif')
        else
        begin
          t := ExtractFilePath(Application.ExeName) + 'weather\a_' + my[8];
        if FileExists(t) then
          Image3.Picture.LoadFromFile(t);
        end;
        if Image3.Picture.Graphic = nil then
          Image3.Height := 0
        else
          Image3.Height := 50 ;
            t2 := ExtractFilePath(Application.ExeName) +'weather\b_'+ my[9];    if FileExists(t2) then
         Image4.Picture.LoadFromFile(t2)
        else
        begin
          t := ExtractFilePath(Application.ExeName) + 'weather\b_' + my[9];
          if FileExists(t2) then
            Image4.Picture.LoadFromFile(t2);     if Image4.Picture.Graphic = nil then
          Image4.Height := 0
          else
          Image4.Height := 50
         end;
      

  2.   


    你用THTTPRIO我没试过,我是直接用DELPHI从中国天气导入WEBSERVICE单元,
    然后:
            FWeatherWebServiceSoap:=WEBSERVICE单元.GetWeatherWebServiceSoap();
            Debug('根据城市编码获取天气信息(编码:'+ACityCode+')');
            FWeatherWebServiceSoap.getWeatherbyCityName(ACityCode);
    就是这样,天气预报的接口也有可能,像中国天气的免费接口,同电脑当天只能访问五次还是十次,
    而且天气图标和天气界面的制作,呵呵,,我当时也花了差不多一个月。。
    加油吧!