delphi中调用webservice时,出错,请大虾帮忙~~~
时间:2011-09-05
来源:互联网
--这是我写的函数
function Tfrm_login.InitADAuth: string;
var
furls: string;
Iservice : ADAuthSoap;
begin
//取WS地址
QueryOpen(tempquery1,'select top 1 * from pln_message where class_id = ''ADAuth'' and remark = ''ccc'' ');
if not tempquery1.Isempty then
begin
//验证
Iservice := GetADAuthSoap(true,'http://svn.ccin.com/MOAWebService/ADAuth.asmx?WSDL');
result := Iservice.ADAuthByFlag(UserName,password,tempquery1.Fieldbyname('mes_name').asstring);
end
else
begin
result := 'false';
Iservice.free;
end;
end;
调用如下webservice
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://svn.ccin.com/MOAWebService/ADAuth.asmx?wsdl
// Encoding : utf-8
// Version : 1.0
// (2011-9-4 13:43:12 - $Revision: 1.9.1.0.1.0.1.9 $)
// ************************************************************************ //
unit ADAuth;
interface
uses InvokeRegistry, 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/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : ADAuthSoap
// service : ADAuth
// port : ADAuthSoap
// URL : http://svn.ccin.com/MOAWebService/ADAuth.asmx
// ************************************************************************ //
ADAuthSoap = interface(IInvokable)
['{56D59372-0D3E-E8B9-1A41-10407C99CD92}']
function IsAuthPass(const strUserName: String; const strPassword: String): String; stdcall;
function ADAuthByFlag(const name: String; const pwd: String; const flag: String): String; stdcall;
end;
function GetADAuthSoap(UseWSDL: Boolean=System.False; Addr: string=''): ADAuthSoap;
implementation
uses SOAPHTTPClient;
function GetADAuthSoap(UseWSDL: Boolean; Addr: string): ADAuthSoap;
const
defWSDL = 'http://svn.ccin.com/MOAWebService/ADAuth.asmx?wsdl';
defURL = 'http://svn.ccin.com/MOAWebService/ADAuth.asmx';
defSvc = 'ADAuth';
defPrt = 'ADAuthSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
RIO := THTTPRIO.Create(nil);
try
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
Result := (RIO as ADAuthSoap);
finally
if Result = nil then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(ADAuthSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ADAuthSoap), 'http://tempuri.org/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(ADAuthSoap), ioDocument);
end.
出现奇怪的问题,按F9进行代码跟踪时,可以从服务器取数据,但直接运行exe文件时,报地址错误
---------------------------
[DEBUG]
---------------------------
Access violation at address 07992334. Write of address 07992334
---------------------------
确定
---------------------------
这是怎么回事啊~~
function Tfrm_login.InitADAuth: string;
var
furls: string;
Iservice : ADAuthSoap;
begin
//取WS地址
QueryOpen(tempquery1,'select top 1 * from pln_message where class_id = ''ADAuth'' and remark = ''ccc'' ');
if not tempquery1.Isempty then
begin
//验证
Iservice := GetADAuthSoap(true,'http://svn.ccin.com/MOAWebService/ADAuth.asmx?WSDL');
result := Iservice.ADAuthByFlag(UserName,password,tempquery1.Fieldbyname('mes_name').asstring);
end
else
begin
result := 'false';
Iservice.free;
end;
end;
调用如下webservice
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://svn.ccin.com/MOAWebService/ADAuth.asmx?wsdl
// Encoding : utf-8
// Version : 1.0
// (2011-9-4 13:43:12 - $Revision: 1.9.1.0.1.0.1.9 $)
// ************************************************************************ //
unit ADAuth;
interface
uses InvokeRegistry, 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/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// binding : ADAuthSoap
// service : ADAuth
// port : ADAuthSoap
// URL : http://svn.ccin.com/MOAWebService/ADAuth.asmx
// ************************************************************************ //
ADAuthSoap = interface(IInvokable)
['{56D59372-0D3E-E8B9-1A41-10407C99CD92}']
function IsAuthPass(const strUserName: String; const strPassword: String): String; stdcall;
function ADAuthByFlag(const name: String; const pwd: String; const flag: String): String; stdcall;
end;
function GetADAuthSoap(UseWSDL: Boolean=System.False; Addr: string=''): ADAuthSoap;
implementation
uses SOAPHTTPClient;
function GetADAuthSoap(UseWSDL: Boolean; Addr: string): ADAuthSoap;
const
defWSDL = 'http://svn.ccin.com/MOAWebService/ADAuth.asmx?wsdl';
defURL = 'http://svn.ccin.com/MOAWebService/ADAuth.asmx';
defSvc = 'ADAuth';
defPrt = 'ADAuthSoap';
var
RIO: THTTPRIO;
begin
Result := nil;
if (Addr = '') then
begin
if UseWSDL then
Addr := defWSDL
else
Addr := defURL;
end;
RIO := THTTPRIO.Create(nil);
try
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end else
RIO.URL := Addr;
Result := (RIO as ADAuthSoap);
finally
if Result = nil then
RIO.Free;
end;
end;
initialization
InvRegistry.RegisterInterface(TypeInfo(ADAuthSoap), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(ADAuthSoap), 'http://tempuri.org/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(ADAuthSoap), ioDocument);
end.
出现奇怪的问题,按F9进行代码跟踪时,可以从服务器取数据,但直接运行exe文件时,报地址错误
---------------------------
[DEBUG]
---------------------------
Access violation at address 07992334. Write of address 07992334
---------------------------
确定
---------------------------
这是怎么回事啊~~
作者: csudjf 发布时间: 2011-09-05
至少这句:
Iservice.free;
是没用的,可以注释掉
Iservice.free;
是没用的,可以注释掉
作者: sonicer 发布时间: 2011-09-05
嗯,我在胡乱试,有点抓狂
作者: csudjf 发布时间: 2011-09-05
谁帮忙提点意见,不是delphi环境有问题
作者: csudjf 发布时间: 2011-09-05
谁帮我下啊,一天都在搞这两句代码,崩溃啊,我可以加分的,一句话
作者: csudjf 发布时间: 2011-09-05
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28