25-05-2021, Saat: 15:43
http://deftertransfertest.veriban.com.tr...ervice.svc
Bu adrese oluşturduğum zip dosyasını göndermem gerekiyor. WSDL dosyasını DLL içerisine import ettim fakat dosyayı göndermeye çalıştığım da "Cannot read that as a ZipFile" hatası ile karşılaşıyorum. Dosyayı gönderirken Base64 olarak gönderiyor galiba sorun burada kaynaklanıyor. Zip dosyasını direkt BinaryData şeklinde göndermemiz mümkün mü?
Göndermek için kullandığım function aşağıdaki gibi.
WSDL dosyasındaki kodlar şu şekilde:
Bu adrese oluşturduğum zip dosyasını göndermem gerekiyor. WSDL dosyasını DLL içerisine import ettim fakat dosyayı göndermeye çalıştığım da "Cannot read that as a ZipFile" hatası ile karşılaşıyorum. Dosyayı gönderirken Base64 olarak gönderiyor galiba sorun burada kaynaklanıyor. Zip dosyasını direkt BinaryData şeklinde göndermemiz mümkün mü?
Göndermek için kullandığım function aşağıdaki gibi.
function DefterGonder(kullaniciAdi, parola, dosyaYolu, yil: String;
periyod: Integer): String;
var
myService: IeBookService;
sessionCode: string;
files: TransferDocument;
Zip: TZipFile;
zipArray: TArray<System.Byte>;
loginResult: Boolean;
documentResult: Boolean;
documentNumber: String;
begin
try
try
myService := eBookService.GetIeBookService();
// Ex:=Ex.Create;
// fault := VeribanServiceFault.Create;
Zip := TZipFile.Create;
Zip.Open('C:\Temp\' + ExtractFileName(dosyaYolu).Split(['.'])[0] +
'.zip', zmWrite);
Zip.Add(dosyaYolu);
Zip.Close;
Zip.Open('C:\Temp\' + ExtractFileName(dosyaYolu).Split(['.'])[0] +
'.zip', zmRead);
Zip.Read(0, zipArray);
myService.Login(kullaniciAdi, parola, loginResult, sessionCode);
files := TransferDocument.Create;
files.Period := periyod;
files.Year := yil;
files.FileName := ExtractFileName(dosyaYolu).Split(['.'])[0] + '.zip';
files.BinaryData := zipArray;
myService.Transfer(sessionCode, files, documentResult, documentNumber);
// Result := sessionCode;
Result := loginResult.ToString();
except
on exp: Exception do
begin
Result := exp.Message;
end;
//
end;
finally
FreeAndNil(Zip);
end;
end;
WSDL dosyasındaki kodlar şu şekilde:
unit eBookService;
interface
uses Soap.InvokeRegistry, Soap.SOAPHTTPClient, System.Types, Soap.XSBuiltIns;
const
IS_OPTN = $0001;
IS_NLBL = $0004;
IS_REF = $0080;
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 Embarcadero types; however, they could also
// indicate incorrect WSDL documents that failed to declare or import a schema type.
// ************************************************************************ //
// !:base64Binary - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:int - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:unsignedByte - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:boolean - "http://www.w3.org/2001/XMLSchema"[Gbl]
TransferDocument2 = class; { "http://schemas.datacontract.org/2004/07/eBook.WebService.Models"[GblCplx] }
TransferDocument = class; { "http://schemas.datacontract.org/2004/07/eBook.WebService.Models"[GblElm] }
DataModel2 = class; { "http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models"[GblCplx] }
DataModel = class; { "http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models"[GblElm] }
ConnectorAccountRights2 = class; { "http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models"[GblCplx] }
ConnectorAccountRights = class; { "http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models"[GblElm] }
{$SCOPEDENUMS ON}
{ "http://schemas.datacontract.org/2004/07/eBook.Common.Base"[GblSmpl] }
Enums_BookType = (Journal, Ledger);
{$SCOPEDENUMS OFF}
// ************************************************************************ //
// XML : TransferDocument, global, <complexType>
// Namespace : http://schemas.datacontract.org/2004/07/...ice.Models
// ************************************************************************ //
TransferDocument2 = class(TRemotable)
private
FBinaryData: TArray<System.Byte>;
FBinaryData_Specified: boolean;
FFileName: string;
FFileName_Specified: boolean;
FPeriod: Integer;
FPeriod_Specified: boolean;
FYear: string;
FYear_Specified: boolean;
function GetBinaryData(Index: Integer): TArray<System.Byte>;
procedure SetBinaryData(Index: Integer; const ATArray: TArray<System.Byte>);
function BinaryData_Specified(Index: Integer): boolean;
function GetFileName(Index: Integer): string;
procedure SetFileName(Index: Integer; const Astring: string);
function FileName_Specified(Index: Integer): boolean;
function GetPeriod(Index: Integer): Integer;
procedure SetPeriod(Index: Integer; const AInteger: Integer);
function Period_Specified(Index: Integer): boolean;
function GetYear(Index: Integer): string;
procedure SetYear(Index: Integer; const Astring: string);
function Year_Specified(Index: Integer): boolean;
published
property BinaryData: TArray<System.Byte> Index (IS_OPTN or IS_NLBL) read GetBinaryData write SetBinaryData stored BinaryData_Specified;
property FileName: string Index (IS_OPTN or IS_NLBL) read GetFileName write SetFileName stored FileName_Specified;
property Period: Integer Index (IS_OPTN) read GetPeriod write SetPeriod stored Period_Specified;
property Year: string Index (IS_OPTN or IS_NLBL) read GetYear write SetYear stored Year_Specified;
end;
// ************************************************************************ //
// XML : TransferDocument, global, <element>
// Namespace : http://schemas.datacontract.org/2004/07/...ice.Models
// ************************************************************************ //
TransferDocument = class(TransferDocument2)
private
published
end;
// ************************************************************************ //
// XML : DataModel, global, <complexType>
// Namespace : http://schemas.datacontract.org/2004/07/...ore.Models
// ************************************************************************ //
DataModel2 = class(TRemotable)
private
FData: TArray<System.Byte>;
FData_Specified: boolean;
FUniqueId: string;
FUniqueId_Specified: boolean;
function GetData(Index: Integer): TArray<System.Byte>;
procedure SetData(Index: Integer; const ATArray: TArray<System.Byte>);
function Data_Specified(Index: Integer): boolean;
function GetUniqueId(Index: Integer): string;
procedure SetUniqueId(Index: Integer; const Astring: string);
function UniqueId_Specified(Index: Integer): boolean;
published
property Data: TArray<System.Byte> Index (IS_OPTN or IS_NLBL) read GetData write SetData stored Data_Specified;
property UniqueId: string Index (IS_OPTN or IS_NLBL) read GetUniqueId write SetUniqueId stored UniqueId_Specified;
end;
// ************************************************************************ //
// XML : DataModel, global, <element>
// Namespace : http://schemas.datacontract.org/2004/07/...ore.Models
// ************************************************************************ //
DataModel = class(DataModel2)
private
published
end;
// ************************************************************************ //
// XML : ConnectorAccountRights, global, <complexType>
// Namespace : http://schemas.datacontract.org/2004/07/...ore.Models
// ************************************************************************ //
ConnectorAccountRights2 = class(TRemotable)
private
FAllowToUseEDefter: Boolean;
FAllowToUseEDefter_Specified: boolean;
FAllowToUseEDenetim: Boolean;
FAllowToUseEDenetim_Specified: boolean;
function GetAllowToUseEDefter(Index: Integer): Boolean;
procedure SetAllowToUseEDefter(Index: Integer; const ABoolean: Boolean);
function AllowToUseEDefter_Specified(Index: Integer): boolean;
function GetAllowToUseEDenetim(Index: Integer): Boolean;
procedure SetAllowToUseEDenetim(Index: Integer; const ABoolean: Boolean);
function AllowToUseEDenetim_Specified(Index: Integer): boolean;
published
property AllowToUseEDefter: Boolean Index (IS_OPTN) read GetAllowToUseEDefter write SetAllowToUseEDefter stored AllowToUseEDefter_Specified;
property AllowToUseEDenetim: Boolean Index (IS_OPTN) read GetAllowToUseEDenetim write SetAllowToUseEDenetim stored AllowToUseEDenetim_Specified;
end;
// ************************************************************************ //
// XML : ConnectorAccountRights, global, <element>
// Namespace : http://schemas.datacontract.org/2004/07/...ore.Models
// ************************************************************************ //
ConnectorAccountRights = class(ConnectorAccountRights2)
private
published
end;
// ************************************************************************ //
// Namespace : http://tempuri.org/
// soapAction: http://tempuri.org/IeBookService/%operationName%
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// use : literal
// binding : CustomBinding_IeBookService
// service : eBookService
// port : CustomBinding_IeBookService
// URL : http://deftertransfer.veriban.com.tr/eBookService.svc
// ************************************************************************ //
IeBookService = interface(IInvokable)
['{2FAB8159-6B26-4D5E-B364-EA454B0B248A}']
procedure Login(const userName: string; const password: string; out LoginResult: Boolean; out sessionId: string); stdcall;
procedure Transfer(const sessionId: string; const document: TransferDocument2; out TransferResult: Boolean; out documentNumber: string); stdcall;
procedure TransferWithDivisionDays(const sessionId: string; const document: TransferDocument2; const startDay: Byte; const endDay: Byte; out TransferWithDivisionDaysResult: Boolean; out documentNumber: string
); stdcall;
function GetBookFiles(const sessionId: string; const BookType: Enums_BookType; const Period: Integer; const Year: string; out GetBookFilesResult: Boolean): DataModel2; stdcall;
function GetConnectorAccountRights(const sessionId: string): ConnectorAccountRights2; stdcall;
end;
function GetIeBookService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): IeBookService;
implementation
uses System.SysUtils;
function GetIeBookService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IeBookService;
const
defWSDL = 'http://deftertransfertest.veriban.com.tr/eBookService.svc?wsdl';
defURL = 'http://deftertransfertest.veriban.com.tr/eBookService.svc';
defSvc = 'eBookService';
defPrt = 'CustomBinding_IeBookService';
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 IeBookService);
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;
function TransferDocument2.GetBinaryData(Index: Integer): TArray<System.Byte>;
begin
Result := FBinaryData;
end;
procedure TransferDocument2.SetBinaryData(Index: Integer; const ATArray: TArray<System.Byte>);
begin
FBinaryData := ATArray;
FBinaryData_Specified := True;
end;
function TransferDocument2.BinaryData_Specified(Index: Integer): boolean;
begin
Result := FBinaryData_Specified;
end;
function TransferDocument2.GetFileName(Index: Integer): string;
begin
Result := FFileName;
end;
procedure TransferDocument2.SetFileName(Index: Integer; const Astring: string);
begin
FFileName := Astring;
FFileName_Specified := True;
end;
function TransferDocument2.FileName_Specified(Index: Integer): boolean;
begin
Result := FFileName_Specified;
end;
function TransferDocument2.GetPeriod(Index: Integer): Integer;
begin
Result := FPeriod;
end;
procedure TransferDocument2.SetPeriod(Index: Integer; const AInteger: Integer);
begin
FPeriod := AInteger;
FPeriod_Specified := True;
end;
function TransferDocument2.Period_Specified(Index: Integer): boolean;
begin
Result := FPeriod_Specified;
end;
function TransferDocument2.GetYear(Index: Integer): string;
begin
Result := FYear;
end;
procedure TransferDocument2.SetYear(Index: Integer; const Astring: string);
begin
FYear := Astring;
FYear_Specified := True;
end;
function TransferDocument2.Year_Specified(Index: Integer): boolean;
begin
Result := FYear_Specified;
end;
function DataModel2.GetData(Index: Integer): TArray<System.Byte>;
begin
Result := FData;
end;
procedure DataModel2.SetData(Index: Integer; const ATArray: TArray<System.Byte>);
begin
FData := ATArray;
FData_Specified := True;
end;
function DataModel2.Data_Specified(Index: Integer): boolean;
begin
Result := FData_Specified;
end;
function DataModel2.GetUniqueId(Index: Integer): string;
begin
Result := FUniqueId;
end;
procedure DataModel2.SetUniqueId(Index: Integer; const Astring: string);
begin
FUniqueId := Astring;
FUniqueId_Specified := True;
end;
function DataModel2.UniqueId_Specified(Index: Integer): boolean;
begin
Result := FUniqueId_Specified;
end;
function ConnectorAccountRights2.GetAllowToUseEDefter(Index: Integer): Boolean;
begin
Result := FAllowToUseEDefter;
end;
procedure ConnectorAccountRights2.SetAllowToUseEDefter(Index: Integer; const ABoolean: Boolean);
begin
FAllowToUseEDefter := ABoolean;
FAllowToUseEDefter_Specified := True;
end;
function ConnectorAccountRights2.AllowToUseEDefter_Specified(Index: Integer): boolean;
begin
Result := FAllowToUseEDefter_Specified;
end;
function ConnectorAccountRights2.GetAllowToUseEDenetim(Index: Integer): Boolean;
begin
Result := FAllowToUseEDenetim;
end;
procedure ConnectorAccountRights2.SetAllowToUseEDenetim(Index: Integer; const ABoolean: Boolean);
begin
FAllowToUseEDenetim := ABoolean;
FAllowToUseEDenetim_Specified := True;
end;
function ConnectorAccountRights2.AllowToUseEDenetim_Specified(Index: Integer): boolean;
begin
Result := FAllowToUseEDenetim_Specified;
end;
initialization
{ IeBookService }
InvRegistry.RegisterInterface(TypeInfo(IeBookService), 'http://tempuri.org/', 'utf-8');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IeBookService), 'http://tempuri.org/IeBookService/%operationName%');
InvRegistry.RegisterInvokeOptions(TypeInfo(IeBookService), ioDocument);
InvRegistry.RegisterInvokeOptions(TypeInfo(IeBookService), ioSOAP12);
{ IeBookService.Login }
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'Login', 'userName', '',
'', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'Login', 'password', '',
'', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'Login', 'sessionId', '',
'', IS_NLBL);
{ IeBookService.Transfer }
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'Transfer', 'sessionId', '',
'', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'Transfer', 'document', '',
'[Namespace="http://schemas.datacontract.org/2004/07/eBook.WebService.Models"]', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'Transfer', 'documentNumber', '',
'', IS_NLBL);
{ IeBookService.TransferWithDivisionDays }
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'TransferWithDivisionDays', 'sessionId', '',
'', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'TransferWithDivisionDays', 'document', '',
'[Namespace="http://schemas.datacontract.org/2004/07/eBook.WebService.Models"]', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'TransferWithDivisionDays', 'documentNumber', '',
'', IS_NLBL);
{ IeBookService.GetBookFiles }
InvRegistry.RegisterMethodInfo(TypeInfo(IeBookService), 'GetBookFiles', '',
'[ReturnName="result"]', IS_OPTN or IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'GetBookFiles', 'sessionId', '',
'', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'GetBookFiles', 'BookType', '',
'[Namespace="http://schemas.datacontract.org/2004/07/eBook.Common.Base"]');
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'GetBookFiles', 'Year', '',
'', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'GetBookFiles', 'result', '',
'[Namespace="http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models"]', IS_NLBL);
{ IeBookService.GetConnectorAccountRights }
InvRegistry.RegisterMethodInfo(TypeInfo(IeBookService), 'GetConnectorAccountRights', '',
'[ReturnName="GetConnectorAccountRightsResult"]', IS_OPTN or IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'GetConnectorAccountRights', 'sessionId', '',
'', IS_NLBL);
InvRegistry.RegisterParamInfo(TypeInfo(IeBookService), 'GetConnectorAccountRights', 'GetConnectorAccountRightsResult', '',
'[Namespace="http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models"]', IS_NLBL);
RemClassRegistry.RegisterXSClass(TransferDocument2, 'http://schemas.datacontract.org/2004/07/eBook.WebService.Models', 'TransferDocument2', 'TransferDocument');
RemClassRegistry.RegisterXSClass(TransferDocument, 'http://schemas.datacontract.org/2004/07/eBook.WebService.Models', 'TransferDocument');
RemClassRegistry.RegisterXSInfo(TypeInfo(Enums_BookType), 'http://schemas.datacontract.org/2004/07/eBook.Common.Base', 'Enums_BookType', 'Enums.BookType');
RemClassRegistry.RegisterXSClass(DataModel2, 'http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models', 'DataModel2', 'DataModel');
RemClassRegistry.RegisterXSClass(DataModel, 'http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models', 'DataModel');
RemClassRegistry.RegisterXSClass(ConnectorAccountRights2, 'http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models', 'ConnectorAccountRights2', 'ConnectorAccountRights');
RemClassRegistry.RegisterXSClass(ConnectorAccountRights, 'http://schemas.datacontract.org/2004/07/eBook.Services.Core.Models', 'ConnectorAccountRights');
end.

