Delphi 当WSDL可调用接口方法调用时发生访问冲突错误。。。?
我想在delphi中使用服务(WSDL导入器),但我不能这样做,因为在调用此代码时引发了错误“地址处的访问冲突…” 接口:Delphi 当WSDL可调用接口方法调用时发生访问冲突错误。。。?,delphi,wsdl,Delphi,Wsdl,我想在delphi中使用服务(WSDL导入器),但我不能这样做,因为在调用此代码时引发了错误“地址处的访问冲突…” 接口: SendLetterService = interface(IInvokable) ['{FFACC70E-33A0-5413-E720-F5421944C864}'] function sendLetters(const parameters: sendLetters):sendLettersResponse; stdcall; functio
SendLetterService = interface(IInvokable)
['{FFACC70E-33A0-5413-E720-F5421944C864}']
function sendLetters(const parameters: sendLetters):sendLettersResponse; stdcall;
function getLetterType(const parameters: getLetterType):getLetterTypeResponse; stdcall;
function getOrgLetterType(const parameters: getOrgLetterType):getOrgLetterTypeResponse; stdcall;
function getOrgForms(const parameters: getOrgForms):getOrgFormsResponse; stdcall;
end;
function GetSendLetterService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): SendLetterService;
implementation
function GetSendLetterService(UseWSDL: Boolean; Addr: string;HTTPRIO:THTTPRIO): SendLetterService;
const
defWSDL = 'E:\delphi\TSN0\sendletter.xml';
defURL = 'http://10.0.233.254/ebox/sendletter?wsdl';
defSvc = 'SendLetterServicePortBindingQSService';
defPrt = 'SendLetterServicePortBindingQSPort';
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
if UseWSDL then
begin
RIO.WSDLLocation := Addr;
RIO.Service := defSvc;
RIO.Port := defPrt;
end
else
RIO.URL := Addr;
Result := (RIO as SendLetterService);
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;
end;
*******调用方法******的我的代码
procedure TForm1.btnRcvLetterTypesClick(Sender: TObject);
var
Response : getLetterTypeResponse;
glt : getLetterType;
Srv : SendLetterService;
begin
Response := getLetterTypeResponse.Create;
glt := getLetterType.Create;
try
Srv := GetSendLetterService(True,'');
if Assigned(Srv) then
{======= Access Violation?????? ===========}
Response := Srv.getLetterType(glt);
{======= Access Violation?????? ===========}
finally
Response.Free;
glt.Free;
end;
end;
当点击该按钮时,该代码正在运行,但在{=}部分引发了错误。。。
请帮助我…完整的代码:
创建WSDL导入的接口:
type
sendLetterAttach = class;
Array_Of_sendLetterAttach = array of sendLetterAttach;
sendLetterAttach = class(TRemotable)
private
FfileData: TByteDynArray;
FfileData_Specified: boolean;
FfileName: string;
FfileName_Specified: boolean;
procedure SetfileData(Index: Integer; const ATByteDynArray: TByteDynArray);
function fileData_Specified(Index: Integer): boolean;
procedure SetfileName(Index: Integer; const Astring: string);
function fileName_Specified(Index: Integer): boolean;
published
property fileData: TByteDynArray Index (IS_OPTN or IS_UNQL) read FfileData
write SetfileData stored fileData_Specified;
property fileName: string Index (IS_OPTN or IS_UNQL) read FfileName
write SetfileName stored fileName_Specified;
end;
getLetterTypeResponseType = array of string;
SendLetterService = interface(IInvokable)
['{FFACC70E-33A0-5413-E720-F5421944C864}']
function sendLetters(const orgCode: string; const orgUser: string;
const orgUserPassword: string; const letterTypeCode: string;
const orgLetterTypeCode: string; const letterSubject: string;
const letterText: string; const letterOfficialNO: string;
const letterOfficialDate: string; const letterCanDelete: Int64;
const letterCanReply: Int64; const lettterReplyDueDate: string;
const letterPaymentNo: string; const formCode: string;
const InPersonAuthentication: Int64;
const people: getLetterTypeResponseType;
const attachments: Array_Of_sendLetterAttach): string; stdcall;
function getLetterType(const orgCode: string; const orgUser: string;
const orgUserPassword: string): getLetterTypeResponseType; stdcall;
function getOrgLetterType(const orgCode: string; const orgUser: string;
const orgUserPassword: string;
const letterTypeCode: string):getLetterTypeResponseType; stdcall;
function getOrgForms(const orgCode: string; const orgUser: string;
const orgUserPassword: string): getLetterTypeResponseType; stdcall;
end;
function GetSendLetterService(UseWSDL: Boolean=System.False; Addr: string='';
HTTPRIO: THTTPRIO = nil): SendLetterService;
implementation
uses SysUtils;
function GetSendLetterService(UseWSDL: Boolean; Addr: string; HTTPRIO:
THTTPRIO): SendLetterService;
const
defWSDL = 'http://10.0.233.254/ebox/sendletter?wsdl';
defURL = 'http://10.0.233.254/ebox/sendletter';
defSvc = 'SendLetterServicePortBindingQSService';
defPrt = 'SendLetterServicePortBindingQSPort';
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 SendLetterService);
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;
和我调用方法的代码:
procedure TForm1.btnRcvLetterTypesClick(Sender: TObject);
var
Response: getLetterTypeResponseType;
I: Integer;
Srv : SendLetterService;
begin
try
Srv := GetSendLetterService(True);
srv.getLetterType('Code','UserName','Pass');
finally
end;
end;
GPF大多数情况是由未初始化的/NIL指针引起的。如果在被调用的方法中注释掉所有内容会怎么样。GPF也会发生吗?如果是,则某些情况会导致
src
实例化出现问题。如果不是,则错误发生在被调用的方法内部。您说在调用Srv.getLetterType
时会发生异常,但您没有包含Srv.getLetterType
的代码。我们如何理解为什么没有该代码它会引发异常?我们也看不到getLetterType.Create
的代码,这可能会失败并返回nil。当您使用这两种方法时,调试器会告诉您什么?thx Ken White。。。getLetterType
是一种stdcall
方法。。。响应类型为GetLetterTypeResponse
,然后在接口中定义。。。