我想用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;
应该怎样调用里面的方法呢 ?我是蠢菜鸟,请高手指点一二,感激不尽。
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;
应该怎样调用里面的方法呢 ?我是蠢菜鸟,请高手指点一二,感激不尽。
解决方案 »
- delphi循环语句读不出数据
- 为了减少网络流量,我每次只修改从服务器端读取得clientdataset中的一条记录,而且修改完成后必须保存到服务器,请问我如何只提交这一条记录呢
- 怎么清除在image里面自己画的线
- delphi写的dll,被pb调用时非法操作
- 怎么实现象Winddows里一样,给另外一台机器发一条信息,让其显示在对方机器上?
- 有关子窗口的问题。
- 请教DELPHI自带的例子 NETCHAT的问题
- 哪里有比csdn好的Delphi论坛?????
- 阻塞方式发送内容(clientsocket),有一个什么样的函数?
- 怎样将一个stream的数据存入到SQL数据库的TEXT类型中?
- 如何缩短TSocketConnection 连接时间
- 现在大家最常用的封包分析,查看工具是什么
// 下列类型, 提交至 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.
类似如下:
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后面的括号也可以不写。