Нарушение доступа Ошибка при вызове метода вызываемого интерфейса WSDL ...? - PullRequest
0 голосов
/ 15 сентября 2018

Я хочу работать со службой (WSDL IMPORTER) в Delphi, но я не могу этого сделать, потому что возникает ошибка «нарушение доступа по адресу ...», когда я вызываю этот код ...

интерфейс:

 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;

, когда затем нажмите этот код выполнения кода, но возникла ошибка {===} раздел ... пожалуйста, помогите мне ...

1 Ответ

0 голосов
/ 17 сентября 2018

Полный код: созданный интерфейс 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;
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...