Kod: Tümünü seç
unit MainClient;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, IWebService1, BaseForm,
Vcl.ExtCtrls, Editfrht, Memofrht, Vcl.Imaging.GIFImg, dxGDIPlusClasses,
Soap.InvokeRegistry, Soap.Rio, Soap.SOAPHTTPClient;
type
TFormMainClient = class(TFormBase)
PanelAnaMenu: TPanel;
Button1: TButton;
mmoTestData: TMemofrht;
Splitter1: TSplitter;
Panel1: TPanel;
mmoAfter: TMemofrht;
Splitter2: TSplitter;
mmoBefore: TMemofrht;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject); override;
procedure HTTPRIO1BeforeExecute(const MethodName: string;
SOAPRequest: TStream);
procedure HTTPRIO1AfterExecute(const MethodName: string;
SOAPResponse: TStream);
private
public
IServiceERP : IWebService;
procedure SecurityHeaderEkle;
end;
var
FormMainClient: TFormMainClient;
implementation
{$R *.dfm}
uses Genel, Loading;
procedure TFormMainClient.SecurityHeaderEkle;
var
securityHeader: TSecurityHeader;
begin
securityHeader := TSecurityHeader.Create;
try
securityHeader.Identification := 'guvenlik_kodu';
with IServiceERP as ISOAPHeaders do
begin
Send(TSOAPHeader(securityHeader));
end;
finally
// header.Free;
end;
end;
procedure TFormMainClient.Button1Click(Sender: TObject);
var
nIndex: Integer;
kullanicilar : TArKullanicilar;
begin
IServiceERP := GetIWebService();
SecurityHeaderEkle; //**************************BURASI İPTAL
kullanicilar := IServiceERP.GetEmployeeName;
mmoTestData.Clear;
for nIndex := 0 to Length(kullanicilar) - 1 do
begin
mmoTestData.Lines.Add(IntToStr(kullanicilar[nIndex].Id) + ' ' +
BoolToStr(kullanicilar[nIndex].Validity) + ' ' +
kullanicilar[nIndex].KullaniciAdi + ' ' +
kullanicilar[nIndex].KullaniciSifre + ' ' +
BoolToStr(kullanicilar[nIndex].IsAktif) + ' ' +
BoolToStr(kullanicilar[nIndex].IsYonetici) + #13);
end;
end;
procedure TFormMainClient.FormShow(Sender: TObject);
begin
inherited;
ButtonIptal.Caption := CAP_IPTAL_BUTTON;
ButtonSil.Visible := False;
ButtonTamam.Visible := False;
SpinButton.Visible := False;
statBase.Panels.Items[STBAR_KAYIT_SAYISI].Width := 0;
PanelAnaMenu.Parent := PanelMain;
end;
procedure TFormMainClient.HTTPRIO1AfterExecute(const MethodName: string; SOAPResponse: TStream);
begin
inherited;
SOAPResponse.Position := 0;
mmoAfter.Lines.LoadFromStream(SOAPResponse);
end;
procedure TFormMainClient.HTTPRIO1BeforeExecute(const MethodName: string; SOAPRequest: TStream);
begin
inherited;
mmoBefore.Lines.LoadFromStream(SOAPRequest);
end;
end.
Kod: Tümünü seç
// ************************************************************************ //
// The types declared in this file were generated from data read from the
// WSDL File described below:
// WSDL : http://localhost:8080/wsdl/IWebService
// >Import : http://localhost:8080/wsdl/IWebService>0
// >Import : http://localhost:8080/wsdl/IWebService>1
// Version : 1.0
// (30.03.2015 20:57:10 - - $Rev: 69934 $)
// ************************************************************************ //
unit IWebService1;
interface
uses Soap.InvokeRegistry, Soap.SOAPHTTPClient, System.Types, Soap.XSBuiltIns;
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.
// ************************************************************************ //
// !:boolean - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:string - "http://www.w3.org/2001/XMLSchema"[Gbl]
// !:int - "http://www.w3.org/2001/XMLSchema"[Gbl]
TSecurityHeader = class; { "urn:WebServiceImpl"[Hdr][GblCplx] }
TKullanicilar = class; { "urn:WebServiceIntf"[GblCplx] }
// ************************************************************************ //
// XML : TSecurityHeader, global, <complexType>
// Namespace : urn:WebServiceImpl
// Info : Header
// ************************************************************************ //
TSecurityHeader = class(TSOAPHeader)
private
FIdentification: string;
FUserName: string;
FPassword: string;
published
property Identification: string read FIdentification write FIdentification;
property UserName: string read FUserName write FUserName;
property Password: string read FPassword write FPassword;
end;
TArKullanicilar = array of TKullanicilar; { "urn:WebServiceIntf"[GblCplx] }
// ************************************************************************ //
// XML : TKullanicilar, global, <complexType>
// Namespace : urn:WebServiceIntf
// ************************************************************************ //
TKullanicilar = class(TRemotable)
private
FId: Integer;
FValidity: Boolean;
FKullaniciAdi: string;
FKullaniciSifre: string;
FIsAktif: Boolean;
FIsYonetici: Boolean;
published
property Id: Integer read FId write FId;
property Validity: Boolean read FValidity write FValidity;
property KullaniciAdi: string read FKullaniciAdi write FKullaniciAdi;
property KullaniciSifre: string read FKullaniciSifre write FKullaniciSifre;
property IsAktif: Boolean read FIsAktif write FIsAktif;
property IsYonetici: Boolean read FIsYonetici write FIsYonetici;
end;
// ************************************************************************ //
// Namespace : urn:WebServiceIntf-IWebService
// soapAction: urn:WebServiceIntf-IWebService#GetEmployeeName
// transport : http://schemas.xmlsoap.org/soap/http
// style : rpc
// use : encoded
// binding : IWebServicebinding
// service : IWebServiceservice
// port : IWebServicePort
// URL : http://localhost:8080/soap/IWebService
// ************************************************************************ //
IWebService = interface(IInvokable)
['{F394E00A-013A-602A-29BF-70E6DD13CF52}']
// Headers: TSecurityHeader:pInOut
function GetEmployeeName: TArKullanicilar; stdcall;
end;
function GetIWebService(UseWSDL: Boolean=System.False; Addr: string=''; HTTPRIO: THTTPRIO = nil): IWebService;
var
RIO: THTTPRIO;
implementation
uses System.SysUtils, BaseForm, MainClient;
function GetIWebService(UseWSDL: Boolean; Addr: string; HTTPRIO: THTTPRIO): IWebService;
const
defWSDL = 'http://localhost:8080/wsdl/IWebService';
defURL = 'http://localhost:8080/soap/IWebService';
defSvc = 'IWebServiceservice';
defPrt = 'IWebServicePort';
var
securityHeader: TSecurityHeader;
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;
// securityHeader := TSecurityHeader.Create;
// securityHeader.Identification := 'guvenlik_kodu';
// RIO.SOAPHeaders.Send(TSOAPHeader(securityHeader));
RIO.OnAfterExecute := FormMainClient.HTTPRIO1AfterExecute;
RIO.OnBeforeExecute := FormMainClient.HTTPRIO1BeforeExecute;
try
Result := (RIO as IWebService);
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;
initialization
{ IWebService }
InvRegistry.RegisterInterface(TypeInfo(IWebService), 'urn:WebServiceIntf-IWebService', '');
InvRegistry.RegisterDefaultSOAPAction(TypeInfo(IWebService), 'urn:WebServiceIntf-IWebService#GetEmployeeName');
InvRegistry.RegisterHeaderClass(TypeInfo(IWebService), TSecurityHeader, 'TSecurityHeader', 'urn:WebServiceImpl');
RemClassRegistry.RegisterXSClass(TSecurityHeader, 'urn:WebServiceImpl', 'TSecurityHeader');
RemClassRegistry.RegisterXSInfo(TypeInfo(TArKullanicilar), 'urn:WebServiceIntf', 'TArKullanicilar');
RemClassRegistry.RegisterXSClass(TKullanicilar, 'urn:WebServiceIntf', 'TKullanicilar');
end.
Kod: Tümünü seç
unit WebServiceIntf;
interface
uses
Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns, System.Classes,
Data.DB, ZAbstractRODataset, ZAbstractDataset, ZDataset, ZAbstractConnection,
ZConnection, DatabaseModel;
type
TKullanicilar = class(TRemotable)
private
FId : Integer;
FValidity : Boolean;
FKullaniciAdi : AnsiString;
FKullaniciSifre : AnsiString;
FIsAktif : Boolean;
FIsYonetici : Boolean;
published
property Id : Integer read FId write FId;
property Validity : Boolean read FValidity write FValidity;
property KullaniciAdi : AnsiString read FKullaniciAdi write FKullaniciAdi;
property KullaniciSifre : AnsiString read FKullaniciSifre write FKullaniciSifre;
property IsAktif : Boolean read FIsAktif write FIsAktif;
property IsYonetici : Boolean read FIsYonetici write FIsYonetici;
public
constructor Create();
end;
TArKullanicilar = array of TKullanicilar;
IWebService = interface(IInvokable)
['{4FC64738-DE88-4D55-AD47-8E697DADAB99}']
function GetEmployeeName(): TArKullanicilar; stdcall;
end;
implementation
constructor TKullanicilar.Create();
begin
inherited;
//
end;
initialization
{ Invokable interfaces must be registered }
InvRegistry.RegisterInterface(TypeInfo(IWebService));
end.
Kod: Tümünü seç
unit WebServiceImpl;
interface
uses
Soap.InvokeRegistry, System.Types, Soap.XSBuiltIns, WebServiceIntf, System.Classes,
Data.DB, ZAbstractRODataset, ZAbstractDataset, ZDataset, ZAbstractConnection,
ZConnection, System.SysUtils, DatabaseModel;
type
TSecurityHeader = class(TSOAPHeader)
private
FIdentification: string;
FPassword: string;
FUserName: string;
procedure SetIdentification(const Value: string);
procedure SetPassword(const Value: string);
procedure SetUserName(const Value: string);
published
property Identification : string read FIdentification write SetIdentification;
property UserName : string read FUserName write SetUserName;
property Password : string read FPassword write SetPassword;
end;
type
TWebService = class(TInvokableClass, IWebService)
public
model : TDatabaseModel;
secureHeader : TSecurityHeader;
function GetEmployeeName(): TArKullanicilar; stdcall;
procedure checkHeader(); stdcall;
end;
implementation
procedure TWebService.checkHeader;
var header : TSecurityHeader;
begin
with Self as ISOAPHeaders do
begin
Get(TSecurityHeader, TSOAPHeader(header));
if (header = nil) or (TSecurityHeader(header).Identification <> 'guvenlik_kodu') then
begin
raise Exception.Create('header bilgisi yok veya doğru degil');
end;
end;
end;
function TWebService.GetEmployeeName: TArKullanicilar; stdcall;
var nIndex : Integer;
begin
checkHeader; //**************************BURASI İPTAL
model := TDatabaseModel.Create(nil);
with model do
begin
Query.Close;
Query.SQL.Clear;
Query.SQL.Text := ' SELECT id, validity, kullanici_adi, kullanici_sifre, is_aktif, is_yonetici FROM kullanicilar ';
Query.Open;
Query.First;
SetLength(Result, Query.RecordCount);
nIndex := 0;
while not Query.Eof do
begin
Result[nIndex] := TKullanicilar.Create;
Result[nIndex].Id := Query.FieldByName('id').AsInteger;
Result[nIndex].Validity := Query.FieldByName('validity').AsBoolean;
Result[nIndex].KullaniciAdi := Query.FieldByName('kullanici_adi').AsAnsiString;
Result[nIndex].KullaniciSifre := Query.FieldByName('kullanici_sifre').AsAnsiString;
Result[nIndex].IsAktif := Query.FieldByName('is_aktif').AsBoolean;
Result[nIndex].IsYonetici := Query.FieldByName('is_yonetici').AsBoolean;
Inc(nIndex);
Query.Next;
end;
end;
end;
procedure TSecurityHeader.SetIdentification(const Value: string);
begin
FIdentification := Value;
end;
procedure TSecurityHeader.SetPassword(const Value: string);
begin
FPassword := Value;
end;
procedure TSecurityHeader.SetUserName(const Value: string);
begin
FUserName := Value;
end;
initialization
{ Invokable classes must be registered }
InvRegistry.RegisterInvokableClass(TWebService);
InvRegistry.RegisterHeaderClass(TypeInfo(IWebService), TSecurityHeader);
end.
hatasını alıyorum.Interface Not Supported
Bulduğum örnekler : http://stackoverflow.com/questions/1375 ... -in-delphihttp://docwiki.embarcadero.com/RADStudi ... AP_Headers