我想用web service获取天气预报 在填好WSDL生成的单元文件中有如下在interface中的方法我想在另一个窗体里面调用 不会调用
 WeatherWSSoap = interface(IInvokable)
  ['{54393593-AC04-4DAB-BBF6-AB948B692BED}']
    function  getRegionDataset: getRegionDatasetResult; stdcall;
    function  getRegionProvince: ArrayOfString; stdcall;
    function  getRegionCountry: ArrayOfString; stdcall;
    function  getSupportCityDataset(const theRegionCode: WideString): 
end;
应该怎样调用里面的方法呢 ?我是蠢菜鸟,请高手指点一二,感激不尽。

解决方案 »

  1.   

    以下是我 新建-其他-web service- wsdl导入器后生成的全部代码  不会调用其中 interface部分unit WeatherWS;interfaceuses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;type  // ************************************************************************ //
      // 下列类型, 提交至 WSDL 文件没有表现在文件中.
      // 它们是其他类型表示或归类的任何一个别名[@]
      // to but never[!] declared in the document. The types from the latter category
      // typically map to predefined/known XML or Borland types; however, they could also 
      // 指示错误的 WSDL 文件声明失败或或导入概要类.
      // ************************************************************************ //
      // !:string          - "http://www.w3.org/2001/XMLSchema"  getRegionDatasetResult = class;               { "http://WebXml.com.cn/" }
      getSupportCityDatasetResult = class;          { "http://WebXml.com.cn/" }  // ************************************************************************ //
      // Namespace : http://WebXml.com.cn/
      // ************************************************************************ //
      getRegionDatasetResult = class(TRemotable)
      private
        Fschema: WideString;
      published
        property schema: WideString read Fschema write Fschema;
      end;  ArrayOfString = array of WideString;          { "http://WebXml.com.cn/" }
      // ************************************************************************ //
      // Namespace : http://WebXml.com.cn/
      // ************************************************************************ //
      getSupportCityDatasetResult = class(TRemotable)
      private
        Fschema: WideString;
      published
        property schema: WideString read Fschema write Fschema;
      end;
      // ************************************************************************ //
      // Namespace : http://WebXml.com.cn/
      // soapAction: http://WebXml.com.cn/%operationName%
      // transport : http://schemas.xmlsoap.org/soap/http
      // binding   : WeatherWSSoap
      // service   : WeatherWS
      // port      : WeatherWSSoap
      // URL       : http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx
      // ************************************************************************ //
      WeatherWSSoap = interface(IInvokable)
      ['{54393593-AC04-4DAB-BBF6-AB948B692BED}']
        function  getRegionDataset: getRegionDatasetResult; stdcall;
        function  getRegionProvince: ArrayOfString; stdcall;
        function  getRegionCountry: ArrayOfString; stdcall;
        function  getSupportCityDataset(const theRegionCode: WideString): getSupportCityDatasetResult; stdcall;
        function  getSupportCityString(const theRegionCode: WideString): ArrayOfString; stdcall;
        function  getWeather(const theCityCode: WideString; const theUserID: WideString): ArrayOfString; stdcall;
      end;function GetWeatherWSSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): WeatherWSSoap;
    implementationfunction GetWeatherWSSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): WeatherWSSoap;
    const
      defWSDL = 'http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl';
      defURL  = 'http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx';
      defSvc  = 'WeatherWS';
      defPrt  = 'WeatherWSSoap';
    var
      RIO: THTTPRIO;
    begin
      Result := nil;
      if (Addr = '') then
      begin
        if UseWSDL then
          Addr := defWSDL
        else
          Addr := defURL;
      end;
      if HTTPRIO = nil then
        RIO := THTTPRIO.Create(nil)
      else
        RIO := HTTPRIO;
      try
        Result := (RIO as WeatherWSSoap);
        if UseWSDL then
        begin
          RIO.WSDLLocation := Addr;
          RIO.Service := defSvc;
          RIO.Port := defPrt;
        end else
          RIO.URL := Addr;
      finally
        if (Result = nil) and (HTTPRIO = nil) then
          RIO.Free;
      end;
    end;
    initialization
      InvRegistry.RegisterInterface(TypeInfo(WeatherWSSoap), 'http://WebXml.com.cn/', 'utf-8');
      InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WeatherWSSoap), 'http://WebXml.com.cn/%operationName%');
      RemClassRegistry.RegisterXSClass(getRegionDatasetResult, 'http://WebXml.com.cn/', 'getRegionDatasetResult');
      RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfString), 'http://WebXml.com.cn/', 'ArrayOfString');
      RemClassRegistry.RegisterXSClass(getSupportCityDatasetResult, 'http://WebXml.com.cn/', 'getSupportCityDatasetResult');end.
      

  2.   

    在你的主单元中 GetWeatherWSSoap.getRegionDataset
    类似如下:
    procedure TForm1.Button1Click(Sender: TObject);
    begin
       GetWeatherWSSoap.(True,'http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx').getRegionDataset;
     
        GetWeatherWSSoap.(True,'http://webservice.webxml.com.cn/WebServices/WeatherWS.asmx').getWeatherend(参数1,参数2);
    .
    .
    .
    end;
    以上几个函数都是同样格式的调用,GetWeatherWSSoap后面的括号也可以不写。
      

  3.   

    GetWeatherWSSoap 后面的“.”去掉,手误,也可如下:WeatherWS.GetWeatherWSSoap().getWeatherend(参数1,参数2);