本人刚接触delphi webservices ,现在有一问题procedure TForm1.Button1Click(Sender: TObject);
var
ss : GeocodeSoap;
sStr:string;
begin
try
ss:= GetGeocodeSoap(false,'');
ss.GetGeocode('116.21444','28.22145'); //Edit1.Text := sStr;
except
on E:Exception do
begin
ShowMessage(e.Message);
end;
end;
end; 调用 GetGeocode 方法的时候报指针错误 'access violation at address 00cd23.write of address 00cd23'
请高手赐教..
下面是源码 // ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost/GEO/Ws/Geocode.asmx?wsdl
// Encoding : utf-8
// Version : 1.0
// (2011-1-24 18:35:03 - 1.33.2.5)
// ************************************************************************ //unit Geocode;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" // ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/GetGeocode
// transport : http://schemas.xmlsoap.org/soap/http
// binding : GeocodeSoap
// service : Geocode
// port : GeocodeSoap
// URL : http://localhost/GEO/Ws/Geocode.asmx
// ************************************************************************ //
GeocodeSoap = interface(IInvokable)
['{C4F18C72-B3E9-5DF5-19AA-6813365712B2}']
function GetGeocode(const Longitude: WideString; const Latitude: WideString): WideString; stdcall;
end;function GetGeocodeSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): GeocodeSoap;
implementationfunction GetGeocodeSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): GeocodeSoap;
const
defWSDL = 'http://localhost/GEO/Ws/Geocode.asmx?wsdl';
defURL = 'http://localhost/GEO/Ws/Geocode.asmx';
defSvc = 'Geocode';
defPrt = 'GeocodeSoap';
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 GeocodeSoap);
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(GeocodeSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(GeocodeSoap), 'http://tempuri.org/GetGeocode');
InvRegistry.RegisterInvokeOptions(TypeInfo(GeocodeSoap), ioDocument);
end.
var
ss : GeocodeSoap;
sStr:string;
begin
try
ss:= GetGeocodeSoap(false,'');
ss.GetGeocode('116.21444','28.22145'); //Edit1.Text := sStr;
except
on E:Exception do
begin
ShowMessage(e.Message);
end;
end;
end; 调用 GetGeocode 方法的时候报指针错误 'access violation at address 00cd23.write of address 00cd23'
请高手赐教..
下面是源码 // ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost/GEO/Ws/Geocode.asmx?wsdl
// Encoding : utf-8
// Version : 1.0
// (2011-1-24 18:35:03 - 1.33.2.5)
// ************************************************************************ //unit Geocode;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" // ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/GetGeocode
// transport : http://schemas.xmlsoap.org/soap/http
// binding : GeocodeSoap
// service : Geocode
// port : GeocodeSoap
// URL : http://localhost/GEO/Ws/Geocode.asmx
// ************************************************************************ //
GeocodeSoap = interface(IInvokable)
['{C4F18C72-B3E9-5DF5-19AA-6813365712B2}']
function GetGeocode(const Longitude: WideString; const Latitude: WideString): WideString; stdcall;
end;function GetGeocodeSoap(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): GeocodeSoap;
implementationfunction GetGeocodeSoap(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): GeocodeSoap;
const
defWSDL = 'http://localhost/GEO/Ws/Geocode.asmx?wsdl';
defURL = 'http://localhost/GEO/Ws/Geocode.asmx';
defSvc = 'Geocode';
defPrt = 'GeocodeSoap';
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 GeocodeSoap);
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(GeocodeSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(GeocodeSoap), 'http://tempuri.org/GetGeocode');
InvRegistry.RegisterInvokeOptions(TypeInfo(GeocodeSoap), ioDocument);
end.
解决方案 »
- WebBrowser 问题 高手进来看看
- 两个输入参数,想得到三个返回值,这样的函数该怎么写?
- IdUDPServer的问题!这句到底什么含义?熟悉的进!
- 关于DrawText函数,怎样才能输出文字到游戏窗口?
- 谁有公交换乘的算法?或思路? 求教!万分感谢!
- 为了方便大家即使讨论,建了一个VB、delphi开发技术讨论固定群2196990,期待精英的加入
- 环境变量什么意思如何使用函数?GetEnvironmentVariable()
- 为什么我做的点歌系统在歌曲切换(放完一首到下一首,或手动切到下一首)时,电脑会闪屏(黑掉一下子又恢复原样),电视屏幕也会闪得很历害,望高
- 使用USB该用什么控件
- DELPHI从一无所知到可以进行开发要学多久?
- 如何不用钩子判断回车键是否被按下呢~?
- 网上下载的businessskinform,能不能用在商业软件上?
http://www.cnblogs.com/scansoft/archive/2007/11/08/953099.html
80分给你了