+ -
当前位置:首页 → 问答吧 → Delphi 调用WebService 出错

Delphi 调用WebService 出错

时间:2011-07-05

来源:互联网

1.新建一个App, 放上一个button, listbox, HTTPRIO
2.新建webservices -> wsdlInmporter 导入你这个网站的Wsdl 让程序知道调用规则
  不出意外会生成个WeatherWebService.pas ,主窗体引用它
  http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl

3.设置HTTPRIO的 port, service, wsdlLocation 会下拉出来
4.写点代码吧
  //得到支持的地区
procedure TForm1.Button1Click(Sender: TObject);
var
  AOS,ss: ArrayOfString;
  I: Integer;
begin
  AOS := (HTTPRIO1 as WeatherWebServiceSoap).getSupportProvince;
  for I := Low(AOS) to High(AOS) do
  Listbox1.Items.Add(AOS[I]); -- 可以把所有省份列出来

但是使用下面代码,出现错误:
  -- 取省份下的城市
  ss := (HTTPRIO1 as WeatherWebServiceSoap).getSupportCity('广西')
  -- 取城市的天气
  ss := (HTTPRIO1 as WeatherWebServiceSoap).getWeatherbyCityName('深圳');

---- 错误信息为:
Project Project1.exe raised exception class ERemotableException with message '服务器无法处理请求。 ---> 未将对象引用设置到对象的实例。'. Process stopped. Use Step or Run to continue.

作者: wudong859   发布时间: 2011-07-05

帮顶 避免杯具

作者: inetfuture   发布时间: 2011-07-07