我想在德尔福中使用服务(WSDL IMPORTER(,但我不能这样做,因为引发错误"地址访问冲突..."当我称之为代码时...
接口:
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:delphiTSN0sendletter.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;