解决方案 »
- 调用dll报错的问题
- 如何将一个real数保留两位小数
- 如何判断 鼠标 在不在 某个组件上 ???急 顶也给分
- delphi的通配符怎么写?
- 【急】【急】【急】求水晶报表for D6的下载,及安装、使用方法
- 谁有《Object Pascal 编程指南 》书?在线等待!
- 急事!!!!!!!!!!!!!!!!!!!!!!!!!!!!!找人做软件!有银子的哦!
- 急:TWebBrowser控件如何消除右边那条难看的ScrollBar
- delphi不能自动打开sql anywhere5.0,是什么原因?
- DELPHI7的TStream为什么不能读取超过10000的BUFFER?
- fastreport 报错
- WebBrowser控件如何载入一个TImage显示的图片?
begin
HTTPRIO1.WSDLLocation := 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl';
HTTPRIO1.Service := 'WeatherWebService';
HTTPRIO1.Port := 'WeatherWebServiceSoap';
// HTTPRIO1.WSDLLocation := 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl';
end;
D2007中测试通过
晕,我的D7不行,难道是RP问题 ?
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, InvokeRegistry, Rio, SOAPHTTPClient, StdCtrls;type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
HTTPRIO1: THTTPRIO;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;implementationuses WeatherWebService;{$R *.dfm}procedure TForm1.FormCreate(Sender: TObject);
begin
HTTPRIO1.WSDLLocation := 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl';
HTTPRIO1.Service := 'WeatherWebService';
HTTPRIO1.Port := 'WeatherWebServiceSoap';
end;procedure TForm1.Button1Click(Sender: TObject);
var
myWp: WeatherWebServiceSoap;
myWS: ArrayOfString;
I: Integer;
begin
myWp := HTTPRIO1 as WeatherWebServiceSoap;
myWS := mywp.getWeatherbyCityName('石家庄'); //变量
for I := Low(myWS) to High(myWS) do
begin
Memo1.Lines.Add(myWS[I]);
end;
end;end.
WeatherWebService
unit WeatherWebService;interfaceuses InvokeRegistry, SOAPHTTPClient, Types, XSBuiltIns;type // ************************************************************************ //
// The following types, referred to in the WSDL document are not being represented
// in this file. They are either aliases[@] of other types represented or were referred
// 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
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:string - "http://www.w3.org/2001/XMLSchema" getSupportDataSetResult = class; { "http://WebXml.com.cn/" } ArrayOfString = array of WideString; { "http://WebXml.com.cn/" }
// ************************************************************************ //
// Namespace : http://WebXml.com.cn/
// ************************************************************************ //
getSupportDataSetResult = 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 : WeatherWebServiceSoap
// service : WeatherWebService
// port : WeatherWebServiceSoap
// URL : http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
// ************************************************************************ //
WeatherWebServiceSoap = interface(IInvokable)
['{0AF62441-3FA0-F5D8-B6B8-B486F32F9DDE}']
function getSupportCity(const byProvinceName: WideString): ArrayOfString; stdcall;
function getSupportProvince: ArrayOfString; stdcall;
function getSupportDataSet: getSupportDataSetResult; stdcall;
function getWeatherbyCityName(const theCityName: WideString): ArrayOfString; stdcall;
function getWeatherbyCityNamePro(const theCityName: WideString; const theUserID: WideString): ArrayOfString; stdcall;
end;function GetWeatherWebServiceSoap(UseWSDL: Boolean = System.False; Addr: string = ''; HTTPRIO: THTTPRIO = nil): WeatherWebServiceSoap;
implementationfunction GetWeatherWebServiceSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): WeatherWebServiceSoap;
const
defWSDL = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl';
defURL = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx';
defSvc = 'WeatherWebService';
defPrt = 'WeatherWebServiceSoap';
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 WeatherWebServiceSoap);
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(WeatherWebServiceSoap), 'http://WebXml.com.cn/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WeatherWebServiceSoap), 'http://WebXml.com.cn/%operationName%');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfString), 'http://WebXml.com.cn/', 'ArrayOfString');
RemClassRegistry.RegisterXSClass(getSupportDataSetResult, 'http://WebXml.com.cn/', 'getSupportDataSetResult');
end.
英雄,给个超详细的代码吧,什么pas,frm全部打包给我吧...怎么就我的不行呢...
initializationInvRegistry.RegisterInvokeOptions(TypeInfo(WeatherWSSoap),ioDocument); //加上这句。
InvRegistry.RegisterInvokeOptions(TypeInfo(WeatherWebServiceSoap),ioDocument);1、WeatherWebService.pas单元中加上这句后,在D7中编译不再报错,可以调用到WebServices,但查不到结果,“查询结果为空!这城市或区域暂时不被支持。”
2、把D2007测试通过的项目在D7中打开,按7楼一样把TXMLdata类相关的注释掉,用D7编译,可以查到结果。河北石家庄5369853698.jpg2010-6-1 14:47:0219℃/30℃6月1日 晴转多云南风3-4级转北风微风0.gif1.gif今日天气实况:气温:27.6℃;风向/风力:东南风 小于3级;湿度:45%;气压:1003.3hPa;空气质量:良;紫外线强度:强穿衣指数:天气炎热,建议着短衫、短裙、短裤、薄型T恤衫、敞领短袖棉衫等清凉夏季服装。
感冒指数:各项气象条件适宜,发生感冒机率较低。但请避免长期处于空调房间中,以防感冒。
晨练指数:早晨气象条件较适宜晨练,但风力稍大,晨练时请注意选择避风的地点,避免迎风锻炼。
洗车指数:不宜洗车,未来24小时内有雨,如果在此期间洗车,雨水和路上的泥水可能会再次弄脏您的爱车。
晾晒指数:万里无云,光照充足,极适宜晾晒。抓紧时机把久未见阳光的衣物搬出来晒晒太阳吧!
旅游指数:天气晴朗,万里无云,是个好天气哦。稍热但是风大,能缓解炎热的感觉,适宜旅游,可不要错过机会呦!
路况指数:晴天,条件适宜,路面比较干燥,路况较好。
舒适度指数:白天天气晴好,您在这种天气条件下,会感觉早晚凉爽、舒适,午后偏热。20℃/30℃6月2日 多云转雷阵雨南风3-4级转北风微风1.gif4.gif18℃/29℃6月3日 阵雨北风3-4级转微风3.gif3.gif石家庄市地处广袤辽阔的华北平原中南部,位于东经114°29′,北纬38°04′,北靠首都北京和港口城市天津,东临渤海和华北油田,西依巍巍太行山脉并与全国煤炭基地山西省毗邻,古称“京畿之地”,素有“南北通衢、燕晋咽喉”之称,地理位置十分优越。石家庄属温带大陆性季风气候,冬季寒冷干燥,多东北风,夏季炎热干燥,多东南风,春秋温和。石家庄旅游资源十分丰富,既有秀美的自然风光,也有珍贵的文物古迹,其中,有国家级风景名胜区嶂石岩、苍岩山、西柏坡-天桂山;有国家级历史文化名城正定;有世界桥梁鼻祖赵州桥为代表的18处国家重点文物保护单位,有新中国的摇篮西柏坡;有国家级森林公园五岳寨;全国十大集贸市场之列的南三条,新华商贸城等一大批各具特色的旅游资源和景点。目前已形成了红色旅游、绿色旅游、古文化旅游、新都市旅游四大系列旅游特色产品,全市现有对外开放且具规模的景区(点)50余处,其中国家4A级景区6处,国家3A级景区3处,国家2A级景区2处。近年来,围绕“红、绿、古、新”四大系列旅游特色产品,我市的旅游环境和旅游服务功能不断完善。旅游者来到石家庄吃、住、行、游、购娱等方面更加舒适和方便。,全市现有星级(饭店)宾馆40家(其中三星级以上17家),各酒店、餐馆汇集了全国各地的风味菜系,娱乐、健身设施遍布市区。
InvRegistry.RegisterInterface(TypeInfo(WeatherWebServiceSoap), 'http://WebXml.com.cn/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(WeatherWebServiceSoap), 'http://WebXml.com.cn/%operationName%');
RemClassRegistry.RegisterXSInfo(TypeInfo(ArrayOfString), 'http://WebXml.com.cn/', 'ArrayOfString');
RemClassRegistry.RegisterXSClass(getSupportDataSetResult, 'http://WebXml.com.cn/', 'getSupportDataSetResult');
InvRegistry.RegisterInvokeOptions(TypeInfo(WeatherWebServiceSoap), ioDocument);//是加载这里吧 ?
加了,编译是没问题,但程序运行时还是提示“未将对象引用设置到对象的实例”。能否提供2007的WeatherWebService.pas ?
先var SWebServiceSoap : WebServiceSoap{webservice引用方法接口}
SWebServiceSoap := (HTTPRIO as WebServiceSoap);
sWebServiceSoap := GetWebServiceSoap(False{必须为false},'http://10.194.35.58/Webservice.asmx',HTTPRIO{httprio实例});
需要引用哪个单元?WeatherWebService.pas里没有定义
procedure TForm1.Button1Click(Sender: TObject);
var
SWebServiceSoap: WebServiceSoap;
myWp: WeatherWebServiceSoap;
myWS: ArrayOfString;
I: Integer;
begin
SWebServiceSoap := (HTTPRIO1 as WebServiceSoap);
SWebServiceSoap := GetWebServiceSoap(False, 'http://10.194.35.58/Webservice.asmx', HTTPRIO1);
myWp := HTTPRIO1 as WeatherWebServiceSoap;
myWS := mywp.getWeatherbyCityName('石家庄'); //变量
for I := Low(myWS) to High(myWS) do
begin
Memo1.Lines.Add(myWS[I]);
end;
end;
begin
HTTPRIO1.WSDLLocation := 'http://srv.mofun.cc/webservice/webservice.dll/wsdl/IWeather';
HTTPRIO1.Service := 'IWeatherservice';
HTTPRIO1.Port := 'IWeatherPort';
end;procedure TForm1.Button1Click(Sender: TObject);
var
myWp: IWeather;
myWS: ArrayOfString;
I: Integer;
begin
memo1.Clear;
myWp := HTTPRIO1 as IWeather;
myWS := mywp.getWeather(Edit1.Text,'',''); //变量
for I := Low(myWS) to High(myWS) do
begin
Memo1.Lines.Add(myWS[I]);
end;
end;
procedure TForm1.mxButton1Click(Sender: TObject);
var
myWp: WeatherWebServiceSoap;
myWS: ArrayOfString;
I: Integer;
begin
HTTPRIO1.HTTPWebNode.UseUTF8InHeader:= true; myWp:= HTTPRIO1 as WeatherWebServiceSoap;
myWS:= mywp.getWeatherbyCityName('昆明');
for I := Low(myWS) to High(myWS) do
begin
mxMemo1.Lines.Add(myWS[I]);
end;
end;
红字一句使D7符合服务端的字符集