Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanırız..

Delphi'de kod yazma ile ilgili sorularınızı bu foruma yazabilirsiniz.
Cevapla
olcaydagli
Üye
Mesajlar: 12
Kayıt: 31 Ara 2003 11:29

Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanırız..

Mesaj gönderen olcaydagli »

Merhaba,
E Fatura konusunda bir Entegratör firma ile anlaştık ancak firmanın bize gönderdiği web service linkine direkt ulaşım yok. Yani bir browser üzerinden yada Delphideki import WSDL bölümünden web servis metodlarına ulaşamıyoruz. Bize web servisin bir kopyasını gönderdiler ve bu kopya üzerinden metodları görüntüleyebiliyoruz. Vermiş oldukları path üzerinden gerçek web servis metodlarına da bize göndermiş oldukları kullanıcı adı ve şifresi ile bağlanabileceğimiz söyleniyor. Bu konuda bize küçük br c# kodu yolladılar. Ancak ben Delphide tam karşılığı nedir çözümleyemedim. Aşağıda göndermiş oldukları c# kod örnklerini veriyorum. Bu konuda yardımcı olabilecek arkadaşlara şimdiden çok teşekkür ederim.

app.config dosyası ayarları...

<system.serviceModel>
<bindings>
<customBinding >
<binding name="ClientEInvoiceServicesBindingIC">
<textMessageEncoding maxReadPoolSize="2147483647" maxWritePoolSize="2147483647"
messageVersion="Soap11" />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="https://testefservicestest.testbank.com ... esPort.svc"
binding="customBinding" bindingConfiguration="ClientEInvoiceServicesBindingIC"
contract="ServiceReference1.IClientEInvoiceServicesPort" name="IClientEInvoiceServicesPort" />
</client>
</system.serviceModel>

Müşteri herhangi bir .NET uygulamasından authentication bilgisini gönderemiyorsa; yukarıdaki binding ayarlarına ilaveten aşağıdaki kodun benzeri ile authentication bilgisini gönderebilir. Bu kod parçası ile Basic Authentication için gerekli olan kullanıcı adı parola bilgisi HttpHeader’a eklenir.

ClientEInvoiceServicesPortClient wsClient = new ClientEInvoiceServicesPortClient();
using (new System.ServiceModel.OperationContextScope((System.ServiceModel.IClientChannel)wsClient.InnerChannel))
{
string authorization = "UserName:Password"; //arada : olacak şekilde aynen bu formatta girilmeli.
byte[] byteArray = System.Text.Encoding.ASCII.GetBytes(authorization);
string base64authorization = Convert.ToBase64String(byteArray); //Base64'e çeviriliyor.
System.ServiceModel.Web.WebOperationContext.Current.OutgoingRequest.Headers.Add(HttpRequestHeader.Authorization, String.Format("Basic {0}", base64authorization)); //Gönderilen request'in header'ına ekleniyor.
wsClient.SendAR(new sendARRequest()); //ilgili metot çağrılıyor.
}
era
Üye
Mesajlar: 17
Kayıt: 01 Oca 2009 09:23

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen era »

Bende buna benzer sorun yaşıyorum viewtopic.php?f=2&t=31818 ben de bi yere kadar getirdm ordan sonra java.lang.NullPointerException hatası alıyorum.
thelvaci
Kıdemli Üye
Mesajlar: 770
Kayıt: 11 Tem 2010 07:17
Konum: Istanbul
İletişim:

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen thelvaci »

TSoapHeader sınıfına bakmalısın olcay.

http://docs.embarcadero.com/products/ra ... eader.html
Kullanıcı avatarı
mussimsek
Admin
Mesajlar: 7586
Kayıt: 10 Haz 2003 12:26
Konum: İstanbul
İletişim:

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen mussimsek »

Delphi'nin hangi sürümünü kullanıyorsunuz? Delphi 7 ise, Delphi 7 sadece basit web service işlemlerini yapabiliyor. Özellikle işin için şifre olayı girince çoğu web servisi desteklemiyor. Biz de benzer bir durumda XE4 indirip, onunla web servisi yazmıştık.

Entegratör firmaların kendi client uygulamaları oluyor. Siz oluşturduğunuz dosyayı bir klasöre koyuyorsunuz, o web servisi kullanarak gönderiyor. Gelen faturaları da alıp bir klasöre koyuyor, siz ordan alıyorsunuz. Böyle bir uygulamalrı varsa ilk olarak böyle birşeyle başlayın...

Kolay gelsin.
olcaydagli
Üye
Mesajlar: 12
Kayıt: 31 Ara 2003 11:29

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen olcaydagli »

thelvaci yazdı:TSoapHeader sınıfına bakmalısın olcay.

http://docs.embarcadero.com/products/ra ... eader.html
Teşekkür ederim hocam, yaklaşık 5 gündür denemediğim yol kalmadı ancak ne hikmetse ve nasıl bir webservice tasarladılar Delphi'de Authorization olayını aşamadım. İşin ilginç kısmı C# ta gayet güzel çalışıyor. Bu arada Delphi Xe3 ve Delphi 2010da denedim ancak olmadı.

Aşağıdaki şekilde TSOAPHeader dan bir sınıf oluşturdum ve bu sınıfı weservice in initialization kısmıda register ettim.

TAuthHeader = class(TSOAPHeader)
private
FAuthorization: string;
published
property Authorization: string read FAuthorization write FAuthorization;
end;

initialization
InvRegistry.RegisterHeaderClass(TypeInfo(ClientEInvoiceServicesPort), TAuthHeader, 'Authentification', '');
RemClassRegistry.RegisterSerializeOptions(TAuthHeader, [xoSimpleTypeWrapper]);

Sonra Yine WebService in GetClientEInvoiceServicesPort(GetWebService gibi) olayında Create edip THTTPRIO nun SOAPHeaders.Send metodu ile gönderdim.

try
.
.
.
finally
if (Result = nil) and (HTTPRIO = nil) then
RIO.Free;
end;

Hdr := TAuthHeader.Create;
Hdr.Authorization := 'Authorization: Basic ' +TIdEncoderMIME.Create(nil).EncodeString('username:password'); //c# ta Base64 olarak şifrelenmiş olduğundan burada şifreli olarak gönderdim.
RIO.SOAPHeaders.Send(Hdr);
thelvaci
Kıdemli Üye
Mesajlar: 770
Kayıt: 11 Tem 2010 07:17
Konum: Istanbul
İletişim:

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen thelvaci »

Register etmene gerek olduğunu düşünmüyorum, o register işi web servisi sen yazıyorsan gerekli. Normalde TSoapHeader'dan türeyen bir sınıf instance'ını oluşturduktan sonra; her web servis metodunu çağırmadan önce Send ile göndermenin yeterli oluyor olması lazım. Bu arada, bir de web servis proxy unitine(Import ettiğin unit) bir bakıber istersen, TSoapHeader'dan türemiş bir sınıf var mı, var ise o sınıfı create edip onu göndermeyi deneyebilirsin.

Örneğin;

Kod: Tümünü seç

  TAuthenticate = class(TSOAPHeader)
  private
    FUserName: string;
    FPassword: string;
  published
    property UserName: string  read FUserName write FUserName;
    property Password: string  read FPassword write FPassword;
  end;

..
..
..
var
  Auth : TAuthenticate;
begin
 Auth := TAuthenticate.Create;
 Auth.UserName := 'User';
 Auth.Password := 'Pass';
 (WebServisArabirimi as ISoapHeaders).Send(Auth);
gibi bir kullanımın işini görmesi lazım normalde.
olcaydagli
Üye
Mesajlar: 12
Kayıt: 31 Ara 2003 11:29

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen olcaydagli »

Maalesef hocam, kontrol ettim ama SoapHeader dan türeyen bir sınıf koymamışlar web service'e, çok fazla zamanım kalmadığından C# ile küçük bir modül yazıp sene sonuna yetiştireceğim inşallah, sonrasında araştırmaya kaldığım yerden devam edebilirim sanıyorum. İlgilendiğin için Allah razı olsun, sağolasın...
era
Üye
Mesajlar: 17
Kayıt: 01 Oca 2009 09:23

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen era »

procedure TForm1.HTTPRIO1BeforeExecute(const MethodName: string;
SOAPRequest: TStream);
var
Stream: TMemoryStream;
StrStream: TStringStream;
XMLdata: TStringList;
begin
SOAPRequest.Position := 0;
XMLData := Tstringlist.Create;
XMLData.Clear;
XMLData.Add('<?xml version="1.0"?> ');

// xml içeriği
.
.
.
.
SOAPRequest.Seek(0,0);
XMLdata.SaveToStream(SOAPRequest);
SOAPRequest.Position := 0;
memo1.Lines.LoadFromStream(SoapRequest);
end;
procedure TForm1.HTTPRIO2AfterExecute(const MethodName: string;
SOAPResponse: TStream);
begin
SOAPResponse.Position:=0;
memo2.Lines.LoadFromStream(SOAPResponse);
SOAPResponse.Position:=0;
end;



bu şekilde yapabilirsin.
akocak1907
Üye
Mesajlar: 1
Kayıt: 18 Ara 2013 10:25

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen akocak1907 »

Olcay kardeşim selam,

bende aynı dertten yakınıyordum. ama sonunda buldum.

procedure TForm1.HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp;
Data: Pointer);
var
authorization : string;
base64authorization : string;
b64 : TIdEncoderMIME;
begin

b64 := TIdEncoderMIME.Create(nil);

authorization := 'admin123:admin123';
base64authorization :='Authorization: Basic '+ b64.EncodeString(authorization);
HttpAddRequestHeaders(Data, PChar(base64authorization), Length(base64authorization),HTTP_ADDREQ_FLAG_ADD );
end;

kolay gelsin......
aliemreilhan
Üye
Mesajlar: 1
Kayıt: 17 Şub 2014 03:39

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen aliemreilhan »

Merhaba Arkadaşım,

aynı konu ile iki gün uğraştıktan sonra, çözümünü sana yazmadan geçmek istemedim. InGef delphi bağlantısında yapılması gerekeni aşağıda bulabilirsin. HTTPRio nun webnode elemanının beforepost olayına aşağıdaki kodu ekle. ayrıca uses a eklemen için base64.pas dosyasının içeriğinide bir altta bulabilirsin.

kolay gelsin.

procedure TForm1.HTTPRIO1HTTPWebNode1BeforePost(const HTTPReqResp: THTTPReqResp;
Data: Pointer);
var
str1: AnsiString;
str2: string;
begin
str1 := Edit3.Text + ':' + Edit4.Text;
base64.Base64Encode(str1,str1);
str1 := 'Authorization: Basic ' + str1;
str2 := str1;
if not HttpAddRequestHeaders(Data, PChar(str2), Length(str2), HTTP_ADDREQ_FLAG_ADD) then
raise Exception.Create(SysErrorMessage(GetLastError));
end;


unit Base64;

{$O+}

interface

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !! THE COMPILER SWITCH MAY BE USED TO ADJUST THE BEHAVIOR !!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

// enable "SpeedDecode"
// the switch to gain speed while decoding the message, however, the codec
// will raise different exceptions/access violations or invalid output if
// the incoming data is invalid or missized.

// disable "SpeedDecode"
// the switch to enable a data check, that will scan the data to decode to
// be valid. This method is to be used if you cannot guarantee to validity
// of the data to be decoded.

{.DEFINE SpeedDecode}

{$IFNDEF SpeedDecode}
{$DEFINE ValidityCheck}
{$ENDIF}


uses SysUtils;


// bestimmt die Größe der Base64-Darstellung
function CalcEncodedSize(InSize: Cardinal): Cardinal;
// bestimmt die Größe der binären Darstellung
function CalcDecodedSize(const InBuffer; InSize: Cardinal): Cardinal;

// codiert einen Buffer in die zugehörige Base64-Darstellung
procedure Base64Encode(const InBuffer; InSize: Cardinal; var OutBuffer); overload; register;
// decodiert die Base64-Darstellung in einen Buffer
{$IFDEF SpeedDecode}
procedure Base64Decode(const InBuffer; InSize: Cardinal; var OutBuffer); overload; register;
{$ENDIF}
{$IFDEF ValidityCheck}
function Base64Decode(const InBuffer; InSize: Cardinal; var OutBuffer): Boolean; overload; register;
{$ENDIF}

// codiert einen String in die zugehörige Base64-Darstellung
procedure Base64Encode(const InText: PAnsiChar; var OutText: PChar); overload;
// decodiert die Base64-Darstellung eines Strings in den zugehörigen String
procedure Base64Decode(const InText: PAnsiChar; var OutText: PChar); overload;

// codiert einen String in die zugehörige Base64-Darstellung
procedure Base64Encode(const InText: AnsiString; var OutText: AnsiString); overload;
// decodiert die Base64-Darstellung eines Strings in den zugehörigen String
procedure Base64Decode(const InText: AnsiString; var OutText: AnsiString); overload;


implementation

const
cBase64Codec: array[0..63] of AnsiChar =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
Base64Filler = '=';

function Base64Encode(const InText: string): string; overload;
begin
Result := Base64Encode(InText);
end;

function Base64Decode(const InText: string): string; overload;
begin
Result := Base64Decode(InText);
end;

function CalcEncodedSize(InSize: Cardinal): Cardinal;
begin
// no buffers passed along, calculate outbuffer size needed
Result := (InSize div 3) shl 2;
if ((InSize mod 3) > 0)
then Inc(Result, 4);
end;

function CalcDecodedSize(const InBuffer; InSize: Cardinal): Cardinal;
type
BA = array of Byte;
begin
Result := 0;
if InSize = 0 then
Exit;
if InSize mod 4 <> 0 then
Exit;
Result := InSize div 4 * 3;
if (BA(InBuffer)[InSize - 2] = Ord(Base64Filler))
then Dec(Result, 2)
else if BA(InBuffer)[InSize - 1] = Ord(Base64Filler)
then Dec(Result);
end;

procedure Base64Encode(const InBuffer; InSize: Cardinal; var OutBuffer
); register;
var
ByThrees, LeftOver: Cardinal;
// reset in- and outbytes positions
asm
// load addresses for source and destination
// PBYTE(InBuffer);
mov ESI, [EAX]
// PBYTE(OutBuffer);
mov EDI, [ECX]
// ByThrees := InSize div 3;
// LeftOver := InSize mod 3;
// load InSize (stored in EBX)
mov EAX, EBX
// load 3
mov ECX, $03
// clear upper 32 bits
xor EDX, EDX
// divide by ECX
div ECX
// save result
mov ByThrees, EAX
// save remainder
mov LeftOver, EDX
// load addresses
lea ECX, cBase64Codec[0]
// while I < ByThrees do
// begin
xor EAX, EAX
xor EBX, EBX
xor EDX, EDX
cmp ByThrees, 0
jz @@LeftOver
@@LoopStart:
// load the first two bytes of the source triplet
LODSW
// write Bits 0..5 to destination
mov BL, AL
shr BL, 2
mov DL, BYTE PTR [ECX + EBX]
// save the Bits 12..15 for later use [1]
mov BH, AH
and BH, $0F
// save Bits 6..11
rol AX, 4
and AX, $3F
mov DH, BYTE PTR [ECX + EAX]
mov AX, DX
// store the first two bytes of the destination quadruple
STOSW
// laod last byte (Bits 16..23) of the source triplet
LODSB
// extend bits 12..15 [1] with Bits 16..17 and save them
mov BL, AL
shr BX, 6
mov DL, BYTE PTR [ECX + EBX]
// save bits 18..23
and AL, $3F
xor AH, AH
mov DH, BYTE PTR [ECX + EAX]
mov AX, DX
// store the last two bytes of the destination quadruple
STOSW
dec ByThrees
jnz @@LoopStart
@@LeftOver:
// there are up to two more bytes to encode
cmp LeftOver, 0
jz @@Done
// clear result
xor EAX, EAX
xor EBX, EBX
xor EDX, EDX
// get left over 1
LODSB
// load the first six bits
shl AX, 6
mov BL, AH
// save them
mov DL, BYTE PTR [ECX + EBX]
// another byte ?
dec LeftOver
jz @@SaveOne
// save remaining two bits
shl AX, 2
and AH, $03
// get left over 2
LODSB
// load next 4 bits
shl AX, 4
mov BL, AH
// save all 6 bits
mov DH, BYTE PTR [ECX + EBX]
shl EDX, 16
// save last 4 bits
shr AL, 2
mov BL, AL
// save them
mov DL, BYTE PTR [ECX + EBX]
// load base 64 'no more data flag'
mov DH, Base64Filler
jmp @@WriteLast4
@@SaveOne:
// adjust the last two bits
shr AL, 2
mov BL, AL
// save them
mov DH, BYTE PTR [ECX + EBX]
shl EDX, 16
// load base 64 'no more data flags'
mov DH, Base64Filler
mov DL, Base64Filler
// ignore jump, as jump reference is next line !
// jmp @@WriteLast4
@@WriteLast4:
// load and adjust result
mov EAX, EDX
ror EAX, 16
// save it to destination
STOSD
@@Done:
end;

{$IFDEF SpeedDecode}
procedure Base64Decode(const InBuffer; InSize: Cardinal; var OutBuffer);
overload; register;
{$ENDIF}
{$IFDEF ValidityCheck}
function Base64Decode(const InBuffer; InSize: Cardinal; var OutBuffer):
Boolean; overload; register;
{$ENDIF}
const
{$IFDEF SpeedDecode}
cBase64Codec: array[0..127] of Byte =
{$ENDIF}
{$IFDEF ValidityCheck}
cBase64Codec: array[0..255] of Byte =
{$ENDIF}
(
$FF, $FF, $FF, $FF, $FF, {005>} $FF, $FF, $FF, $FF, $FF, // 000..009
$FF, $FF, $FF, $FF, $FF, {015>} $FF, $FF, $FF, $FF, $FF, // 010..019
$FF, $FF, $FF, $FF, $FF, {025>} $FF, $FF, $FF, $FF, $FF, // 020..029
$FF, $FF, $FF, $FF, $FF, {035>} $FF, $FF, $FF, $FF, $FF, // 030..039
$FF, $FF, $FF, $3E, $FF, {045>} $FF, $FF, $3F, $34, $35, // 040..049
$36, $37, $38, $39, $3A, {055>} $3B, $3C, $3D, $FF, $FF, // 050..059
$FF, $FF, $FF, $FF, $FF, {065>} $00, $01, $02, $03, $04, // 060..069
$05, $06, $07, $08, $09, {075>} $0A, $0B, $0C, $0D, $0E, // 070..079
$0F, $10, $11, $12, $13, {085>} $14, $15, $16, $17, $18, // 080..089
$19, $FF, $FF, $FF, $FF, {095>} $FF, $FF, $1A, $1B, $1C, // 090..099
$1D, $1E, $1F, $20, $21, {105>} $22, $23, $24, $25, $26, // 100..109
$27, $28, $29, $2A, $2B, {115>} $2C, $2D, $2E, $2F, $30, // 110..119
$31, $32, $33, $FF, $FF, {125>} $FF, $FF, $FF // 120..127

{$IFDEF ValidityCheck}
{125>} , $FF, $FF, // 128..129
$FF, $FF, $FF, $FF, $FF, {135>} $FF, $FF, $FF, $FF, $FF, // 130..139
$FF, $FF, $FF, $FF, $FF, {145>} $FF, $FF, $FF, $FF, $FF, // 140..149
$FF, $FF, $FF, $FF, $FF, {155>} $FF, $FF, $FF, $FF, $FF, // 150..159
$FF, $FF, $FF, $FF, $FF, {165>} $FF, $FF, $FF, $FF, $FF, // 160..169
$FF, $FF, $FF, $FF, $FF, {175>} $FF, $FF, $FF, $FF, $FF, // 170..179
$FF, $FF, $FF, $FF, $FF, {185>} $FF, $FF, $FF, $FF, $FF, // 180..189
$FF, $FF, $FF, $FF, $FF, {195>} $FF, $FF, $FF, $FF, $FF, // 190..199
$FF, $FF, $FF, $FF, $FF, {205>} $FF, $FF, $FF, $FF, $FF, // 200..209
$FF, $FF, $FF, $FF, $FF, {215>} $FF, $FF, $FF, $FF, $FF, // 210..219
$FF, $FF, $FF, $FF, $FF, {225>} $FF, $FF, $FF, $FF, $FF, // 220..229
$FF, $FF, $FF, $FF, $FF, {235>} $FF, $FF, $FF, $FF, $FF, // 230..239
$FF, $FF, $FF, $FF, $FF, {245>} $FF, $FF, $FF, $FF, $FF, // 240..249
$FF, $FF, $FF, $FF, $FF, {255>} $FF // 250..255
{$ENDIF}
);
asm
push EBX
mov ESI, [EAX]
mov EDI, [ECX]
{$IFDEF ValidityCheck}
mov EAX, InSize
and EAX, $03
cmp EAX, $00
jz @@DecodeStart
jmp @@ErrorDone
@@DecodeStart:
{$ENDIF}
mov EAX, InSize
shr EAX, 2
jz @@Done
lea ECX, cBase64Codec[0]
xor EBX, EBX
dec EAX
jz @@LeftOver
push EBP
mov EBP, EAX
@@LoopStart:
// load four bytes into EAX
LODSD
// save them to EDX as AX is used to store results
mov EDX, EAX
// get bits 0..5
mov BL, DL
// decode
mov AH, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AH, $FF
jz @@ErrorDoneAndPopEBP
{$ENDIF}
// get bits 6..11
mov BL, DH
// decode
mov AL, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AL, $FF
jz @@ErrorDoneAndPopEBP
{$ENDIF}
// align last 6 bits
shl AL, 2
// get first 8 bits
ror AX, 6
// store first byte
STOSB
// align remaining 4 bits
shr AX, 12
// get next two bytes from source quad
shr EDX, 16
// load bits 12..17
mov BL, DL
// decode
mov AH, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AH, $FF
jz @@ErrorDoneAndPopEBP
{$ENDIF}
// align ...
shl AH, 2
// ... and adjust
rol AX, 4
// get last bits 18..23
mov BL, DH
// decord
mov BL, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp BL, $FF
jz @@ErrorDoneAndPopEBP
{$ENDIF}
// enter in destination word
or AH, BL
// and store to destination
STOSW
// more coming ?
dec EBP
jnz @@LoopStart
pop EBP
// no
// last four bytes are handled separately, as special checking is needed
// on the last two bytes (may be end of data signals '=' or '==')
@@LeftOver:
// get the last four bytes
LODSD
// save them to EDX as AX is used to store results
mov EDX, EAX
// get bits 0..5
mov BL, DL
// decode
mov AH, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AH, $FF
jz @@ErrorDone
{$ENDIF}
// get bits 6..11
mov BL, DH
// decode
mov AL, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AL, $FF
jz @@ErrorDone
{$ENDIF}
// align last 6 bits
shl AL, 2
// get first 8 bits
ror AX, 6
// store first byte
STOSB
// get next two bytes from source quad
shr EDX, 16
// check DL for "end of data signal"
cmp DL, Base64Filler
jz @@SuccessDone
// align remaining 4 bits
shr AX, 12
// load bits 12..17
mov BL, DL
// decode
mov AH, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp AH, $FF
jz @@ErrorDone
{$ENDIF}
// align ...
shl AH, 2
// ... and adjust
rol AX, 4
// store second byte
STOSB
// check DH for "end of data signal"
cmp DH, Base64Filler
jz @@SuccessDone
// get last bits 18..23
mov BL, DH
// decord
mov BL, BYTE PTR [ECX + EBX]
{$IFDEF ValidityCheck}
// check valid code
cmp BL, $FF
jz @@ErrorDone
{$ENDIF}
// enter in destination word
or AH, BL
// AH - AL for saving last byte
mov AL, AH
// store third byte
STOSB
@@SuccessDone:
{$IFDEF ValidityCheck}
mov Result, $01
jmp @@Done
@@ErrorDoneAndPopEBP:
pop EBP
@@ErrorDone:
mov Result, $00
{$ENDIF}
@@Done:
pop EBX
end;

procedure Base64Encode(const InText: PAnsiChar; var OutText: PChar);
var
InSize, OutSize: Cardinal;
begin
// get size of source
InSize := Length(InText);
// calculate size for destination
OutSize := CalcEncodedSize(InSize);
// reserve memory
OutText := StrAlloc(Succ(OutSize));
OutText[OutSize] := #0;
// encode !
Base64Encode(InText, InSize, OutText);
end;

procedure Base64Encode(const InText: AnsiString; var OutText: AnsiString);
overload;
var
InSize, OutSize: Cardinal;
PIn, POut: Pointer;
begin
// get size of source
InSize := Length(InText);
// calculate size for destination
OutSize := CalcEncodedSize(InSize);
// prepare string length to fit result data
SetLength(OutText, OutSize);
PIn := @InText[1];
POut := @OutText[1];
// encode !
Base64Encode(PIn, InSize, POut);
end;

procedure Base64Decode(const InText: PAnsiChar; var OutText: PChar);
overload;
var
InSize, OutSize: Cardinal;
begin
// get size of source
InSize := Length(InText);
// calculate size for destination
OutSize := CalcDecodedSize(InText, InSize);
// reserve memory
OutText := StrAlloc(Succ(OutSize));
OutText[OutSize] := #0;
// encode !
{$IFDEF SpeedDecode}
Base64Decode(InText, InSize, OutText);
{$ENDIF}
{$IFDEF ValidityCheck}
if not Base64Decode(InText, InSize, OutText) then
OutText[0] := #0;
{$ENDIF}
end;

procedure Base64Decode(const InText: AnsiString; var OutText: AnsiString);
overload;
var
InSize, OutSize: Cardinal;
PIn, POut: Pointer;
begin
// get size of source
InSize := Length(InText);
// calculate size for destination
PIn := @InText[1];
OutSize := CalcDecodedSize(PIn, InSize);
// prepare string length to fit result data
SetLength(OutText, OutSize);
FillChar(OutText[1], OutSize, '.');
POut := @OutText[1];
// encode !
{$IFDEF SpeedDecode}
Base64Decode(PIn, InSize, POut);
{$ENDIF}
{$IFDEF ValidityCheck}
if not Base64Decode(PIn, InSize, POut) then
SetLength(OutText, 0);
{$ENDIF}
end;

end.
bilgisaray.ercan
Üye
Mesajlar: 2
Kayıt: 07 Nis 2014 03:49

Re: Web Servislere Kullanıcı Adı ve Şifre İle Nasıl Bağlanır

Mesaj gönderen bilgisaray.ercan »

bende aynı konuda calısıyorum.elinize saglık bu kodlarla sisteme ulastım.ancak ingef sistemine fatura yukleyemedim.nasıl yapabilirim.
Cevapla