base64 server and client sample

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@524 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa 2008-08-07 15:52:40 +00:00
parent 97f4b386da
commit 893c3451b2
14 changed files with 792 additions and 8 deletions

View File

@ -0,0 +1,75 @@
{
This file is part of the Web Service Toolkit
Copyright (c) 2008 by Inoussa OUEDRAOGO
This file is provide under modified LGPL licence
( the files COPYING.modifiedLGPL and COPYING.LGPL).
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
}
{$INCLUDE wst_global.inc}
unit file_logger_extension;
interface
uses
Classes, SysUtils,
logger_extension;
type
{ TFileLoggerServiceExtension
This class require the "LogFileCompleteName" to be set to a valid
file place.
}
TFileLoggerServiceExtension = class(TLoggerServiceExtension)
protected
procedure TraceMessage(const AMsg : string);override;
end;
var
LogFileCompleteName : string;
implementation
uses
syncobjs, base_service_intf, server_service_intf;
var
StreamInstance : TStream = nil;
StreamInstanceLock : TCriticalSection = nil;
{ TFileLoggerServiceExtension }
procedure TFileLoggerServiceExtension.TraceMessage(const AMsg : string);
begin
if ( Length(AMsg) > 0 ) then begin
StreamInstanceLock.Acquire();
try
if ( StreamInstance = nil ) then begin
if ( Length(LogFileCompleteName) = 0 ) then
raise Exception.Create('"LogFileCompleteName" must be set for the TFileLoggerServiceExtension to work.');
StreamInstance := TFileStream.Create(LogFileCompleteName,fmCreate);
StreamInstance.Seek(0,soEnd);
end;
StreamInstance.Write(AMsg[1],Length(AMsg));
finally
StreamInstanceLock.Release();
end;
end;
end;
initialization
StreamInstanceLock := TCriticalSection.Create();
GetServiceExtensionRegistry().Register('TFileLoggerServiceExtension',TSimpleItemFactory.Create(TFileLoggerServiceExtension) as IItemFactory);
finalization
FreeAndNil(StreamInstance);
FreeAndNil(StreamInstanceLock);
end.

View File

@ -1,6 +1,6 @@
{
This file is part of the Web Service Toolkit
Copyright (c) 2006 by Inoussa OUEDRAOGO
Copyright (c) 2006, 2007, 2008 by Inoussa OUEDRAOGO
This file is provide under modified LGPL licence
( the files COPYING.modifiedLGPL and COPYING.LGPL).
@ -18,16 +18,13 @@ interface
uses
Classes, SysUtils, base_service_intf, server_service_intf;
{$INCLUDE wst.inc}
{$INCLUDE wst_delphi.inc}
type
{ TLoggerServiceExtension }
TLoggerServiceExtension = class(TSimpleFactoryItem,IServiceExtension)
private
procedure TraceMessage(const AMsg : string);
protected
procedure TraceMessage(const AMsg : string);virtual;
protected
procedure ProcessMessage(
const AMessageStage : TMessageStage;
@ -48,7 +45,8 @@ uses TypInfo;
procedure TLoggerServiceExtension.TraceMessage(const AMsg: string);
begin
WriteLn(AMsg);
if IsConsole then
WriteLn(AMsg);
end;
procedure TLoggerServiceExtension.ProcessMessage(
@ -60,6 +58,10 @@ var
s : string;
rqb : IRequestBuffer;
frmtr : IFormatterResponse;
rb : IRequestBuffer;
strm : TStream;
oldPos : Int64;
locStream : TStringStream;
begin
s := GetEnumName(TypeInfo(TMessageStage),Ord(AMessageStage));
case AMessageStage of
@ -67,6 +69,20 @@ begin
begin
rqb := AMsgData as IRequestBuffer;
s := Format('Called service : "%s"; Processing stage : "%s"',[rqb.GetTargetService(),s]);
rb := AMsgData as IRequestBuffer;
if ( AMessageStage = msBeforeDeserialize ) then
strm := rb.GetContent()
else
strm := rb.GetResponse();
oldPos := strm.Position;
locStream := TStringStream.Create('');
try
locStream.CopyFrom(strm,0);
s := Format('%s%s%s',[s,sLineBreak,locStream.DataString]);
finally
strm.Position := oldPos;
locStream.Free();
end;
end;
msAfterDeserialize, msBeforeSerialize :
begin
@ -74,7 +90,7 @@ begin
s := Format('Called service : "%s"; Target Operation = "%s"; Processing stage : "%s"',[frmtr.GetCallTarget(),frmtr.GetCallProcedureName(),s]);
end;
end;
TraceMessage(s);
TraceMessage(Format('%sTimeStamp : %s; %s',[sLineBreak,DateTimeToStr(Now()),s]));
end;
initialization

View File

@ -0,0 +1,39 @@
<?xml version="1.0"?>
<definitions name="urn:base64sample" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="urn:base64sample" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" targetNamespace="urn:base64sample">
<types>
<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:base64sample" targetNamespace="urn:base64sample"/>
</types>
<message name="DuplicateContent">
<part name="AInitialContent" type="xsd:base64Binary"/>
<part name="ARepeatCount" type="xsd:int"/>
</message>
<message name="DuplicateContentResponse">
<part name="result" type="xsd:base64Binary"/>
</message>
<portType name="SampleService">
<document>
<GUID value="{6ACC9331-DD5B-48AA-92ED-F384D144EB1E}"/>
</document>
<operation name="DuplicateContent">
<input message="tns:DuplicateContent"/>
<output message="tns:DuplicateContentResponse"/>
</operation>
</portType>
<binding name="SampleServiceBinding" type="tns:SampleService">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="DuplicateContent">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal" namespace="urn:base64sample"/>
</input>
<output>
<soap:body use="literal" namespace="urn:base64sample"/>
</output>
</operation>
</binding>
<service name="SampleService">
<port name="SampleServicePort" binding="tns:SampleServiceBinding">
<soap:address location="http://127.0.0.1:8000/services/SampleService"/>
</port>
</service>
</definitions>

View File

@ -0,0 +1,71 @@
{
This unit has been produced by ws_helper.
Input unit name : "base64sample".
This unit name : "base64sample".
Date : "07/08/2008 13:25:25".
}
unit base64sample;
{$IFDEF FPC}
{$mode objfpc} {$H+}
{$ENDIF}
{$IFNDEF FPC}
{$DEFINE WST_RECORD_RTTI}
{$ENDIF}
interface
uses SysUtils, Classes, TypInfo, base_service_intf, service_intf;
const
sNAME_SPACE = 'urn:base64sample';
sUNIT_NAME = 'base64sample';
type
SampleService = interface(IInvokable)
['{6ACC9331-DD5B-48AA-92ED-F384D144EB1E}']
function DuplicateContent(
const AInitialContent : TBase64StringRemotable;
const ARepeatCount : integer
):TBase64StringRemotable;
end;
procedure Register_base64sample_ServiceMetadata();
Implementation
uses metadata_repository, record_rtti, wst_types;
procedure Register_base64sample_ServiceMetadata();
var
mm : IModuleMetadataMngr;
begin
mm := GetModuleMetadataMngr();
mm.SetRepositoryNameSpace(sUNIT_NAME, sNAME_SPACE);
mm.SetServiceCustomData(
sUNIT_NAME,
'SampleService',
'TRANSPORT_Address',
'http://127.0.0.1:8000/services/SampleService'
);
mm.SetServiceCustomData(
sUNIT_NAME,
'SampleService',
'FORMAT_Style',
'rpc'
);
mm.SetOperationCustomData(
sUNIT_NAME,
'SampleService',
'DuplicateContent',
'_E_N_',
'DuplicateContent'
);
end;
initialization
End.

View File

@ -0,0 +1,7 @@
GetWSTResourceManager().AddResource('BASE64SAMPLE',
#0#0#0#20'WST_METADATA_0.2.2.0'#0#0#0#12'base64sample'#1#0#0#0#13'SampleServ'
+'ice'#1#0#0#0#16'DuplicateContent'#3#0#0#0#15'AInitialContent'#0#0#0#22'TBas'
+'e64StringRemotable'#0#0#0#0#0#0#0#1#0#0#0#12'ARepeatCount'#0#0#0#7'integer'#0
+#0#0#0#0#0#0#1#0#0#0#6'result'#0#0#0#22'TBase64StringRemotable'#0#0#0#0#0#0#0
+#3''
);

View File

@ -0,0 +1,78 @@
{
This unit has been produced by ws_helper.
Input unit name : "base64sample".
This unit name : "base64sample_proxy".
Date : "07/08/2008 13:25:25".
}
Unit base64sample_proxy;
{$IFDEF FPC} {$mode objfpc}{$H+} {$ENDIF}
Interface
Uses SysUtils, Classes, TypInfo, base_service_intf, service_intf, base64sample;
Type
TSampleService_Proxy=class(TBaseProxy,SampleService)
Protected
class function GetServiceType() : PTypeInfo;override;
function DuplicateContent(
const AInitialContent : TBase64StringRemotable;
const ARepeatCount : integer
):TBase64StringRemotable;
End;
Function wst_CreateInstance_SampleService(const AFormat : string = 'SOAP:'; const ATransport : string = 'HTTP:'):SampleService;
Implementation
uses wst_resources_imp, metadata_repository;
Function wst_CreateInstance_SampleService(const AFormat : string; const ATransport : string):SampleService;
Begin
Result := TSampleService_Proxy.Create('SampleService',AFormat+GetServiceDefaultFormatProperties(TypeInfo(SampleService)),ATransport + 'address=' + GetServiceDefaultAddress(TypeInfo(SampleService)));
End;
{ TSampleService_Proxy implementation }
class function TSampleService_Proxy.GetServiceType() : PTypeInfo;
begin
result := TypeInfo(SampleService);
end;
function TSampleService_Proxy.DuplicateContent(
const AInitialContent : TBase64StringRemotable;
const ARepeatCount : integer
):TBase64StringRemotable;
Var
locSerializer : IFormatterClient;
strPrmName : string;
Begin
locSerializer := GetSerializer();
Try
locSerializer.BeginCall('DuplicateContent', GetTarget(),(Self as ICallContext));
locSerializer.Put('AInitialContent', TypeInfo(TBase64StringRemotable), AInitialContent);
locSerializer.Put('ARepeatCount', TypeInfo(integer), ARepeatCount);
locSerializer.EndCall();
MakeCall();
locSerializer.BeginCallRead((Self as ICallContext));
TObject(Result) := Nil;
strPrmName := 'result';
locSerializer.Get(TypeInfo(TBase64StringRemotable), strPrmName, Result);
Finally
locSerializer.Clear();
End;
End;
initialization
{$i base64sample.wst}
{$IF DECLARED(Register_base64sample_ServiceMetadata)}
Register_base64sample_ServiceMetadata();
{$IFEND}
End.

View File

@ -0,0 +1,68 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="6"/>
<General>
<Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="3">
<Unit0>
<Filename Value="client_sample.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="client_sample"/>
</Unit0>
<Unit1>
<Filename Value="base64sample_proxy.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="base64sample_proxy"/>
</Unit1>
<Unit2>
<Filename Value="base64sample.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="base64sample"/>
</Unit2>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="client_sample.exe"/>
</Target>
<SearchPaths>
<IncludeFiles Value="..\..\..\"/>
<OtherUnitFiles Value="..\..\;..\..\..\;..\..\..\wst_rtti_filter\;$(LazarusDir)\others_package\synapse\"/>
<UnitOutputDirectory Value="obj"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,37 @@
program client_sample;
{$mode objfpc}{$H+}
uses
Classes, SysUtils,
base_service_intf, synapse_http_protocol,
soap_formatter,
base64sample, base64sample_proxy;
var
service : SampleService;
locBuffer, locResBuffer : TBase64StringRemotable;
i : Integer;
s : ansistring;
begin
SYNAPSE_RegisterHTTP_Transport();
locResBuffer := nil;
locBuffer := TBase64StringRemotable.Create();
try
SetLength(s,255);
for i := 1 to Length(s) do
s[i] := Char(i);
locBuffer.BinaryData := s;
service := wst_CreateInstance_SampleService();
locResBuffer := service.DuplicateContent(locBuffer,1);
WriteLn('Input content : ',locBuffer.BinaryData,' Encoded : ',locBuffer.EncodedString);
WriteLn('Output content : ',locResBuffer.BinaryData,' Encoded : ',locResBuffer.EncodedString);
WriteLn('Check = ', ( locResBuffer.BinaryData = s ) );
ReadLn;
finally
locResBuffer.Free();
locBuffer.Free();
end;
end.

View File

@ -0,0 +1,71 @@
{
This unit has been produced by ws_helper.
Input unit name : "base64sample".
This unit name : "base64sample".
Date : "07/08/2008 13:17:40".
}
unit base64sample;
{$IFDEF FPC}
{$mode objfpc} {$H+}
{$ENDIF}
{$IFNDEF FPC}
{$DEFINE WST_RECORD_RTTI}
{$ENDIF}
interface
uses SysUtils, Classes, TypInfo, base_service_intf, service_intf;
const
sNAME_SPACE = 'urn:base64sample';
sUNIT_NAME = 'base64sample';
type
SampleService = interface(IInvokable)
['{6ACC9331-DD5B-48AA-92ED-F384D144EB1E}']
function DuplicateContent(
const AInitialContent : TBase64StringRemotable;
const ARepeatCount : integer
):TBase64StringRemotable;
end;
procedure Register_base64sample_ServiceMetadata();
Implementation
uses metadata_repository, record_rtti, wst_types;
procedure Register_base64sample_ServiceMetadata();
var
mm : IModuleMetadataMngr;
begin
mm := GetModuleMetadataMngr();
mm.SetRepositoryNameSpace(sUNIT_NAME, sNAME_SPACE);
mm.SetServiceCustomData(
sUNIT_NAME,
'SampleService',
'TRANSPORT_Address',
'http://127.0.0.1:8000/services/SampleService'
);
mm.SetServiceCustomData(
sUNIT_NAME,
'SampleService',
'FORMAT_Style',
'rpc'
);
mm.SetOperationCustomData(
sUNIT_NAME,
'SampleService',
'DuplicateContent',
'_E_N_',
'DuplicateContent'
);
end;
initialization
End.

View File

@ -0,0 +1,7 @@
GetWSTResourceManager().AddResource('BASE64SAMPLE',
#0#0#0#20'WST_METADATA_0.2.2.0'#0#0#0#12'base64sample'#1#0#0#0#13'SampleServ'
+'ice'#1#0#0#0#16'DuplicateContent'#3#0#0#0#15'AInitialContent'#0#0#0#22'TBas'
+'e64StringRemotable'#0#0#0#0#0#0#0#1#0#0#0#12'ARepeatCount'#0#0#0#7'integer'#0
+#0#0#0#0#0#0#1#0#0#0#6'result'#0#0#0#22'TBase64StringRemotable'#0#0#0#0#0#0#0
+#3''
);

View File

@ -0,0 +1,127 @@
{
This unit has been produced by ws_helper.
Input unit name : "base64sample".
This unit name : "base64sample_binder".
Date : "07/08/2008 13:17:40".
}
unit base64sample_binder;
{$IFDEF FPC} {$mode objfpc}{$H+} {$ENDIF}
interface
uses SysUtils, Classes, base_service_intf, server_service_intf, base64sample;
type
TSampleService_ServiceBinder = class(TBaseServiceBinder)
protected
procedure DuplicateContentHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
public
constructor Create();
end;
TSampleService_ServiceBinderFactory = class(TInterfacedObject,IItemFactory)
private
FInstance : IInterface;
protected
function CreateInstance():IInterface;
public
constructor Create();
destructor Destroy();override;
end;
procedure Server_service_RegisterSampleServiceService();
Implementation
uses TypInfo, wst_resources_imp,metadata_repository;
{ TSampleService_ServiceBinder implementation }
procedure TSampleService_ServiceBinder.DuplicateContentHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
var
cllCntrl : ICallControl;
objCntrl : IObjectControl;
hasObjCntrl : Boolean;
tmpObj : SampleService;
callCtx : ICallContext;
strPrmName : string;
procName,trgName : string;
AInitialContent : TBase64StringRemotable;
ARepeatCount : integer;
returnVal : TBase64StringRemotable;
begin
callCtx := AContext;
Fillchar(returnVal,SizeOf(TBase64StringRemotable),#0);
Fillchar(AInitialContent,SizeOf(TBase64StringRemotable),#0);
strPrmName := 'AInitialContent'; AFormatter.Get(TypeInfo(TBase64StringRemotable),strPrmName,AInitialContent);
if Assigned(Pointer(AInitialContent)) then
callCtx.AddObjectToFree(TObject(AInitialContent));
strPrmName := 'ARepeatCount'; AFormatter.Get(TypeInfo(integer),strPrmName,ARepeatCount);
tmpObj := Self.GetFactory().CreateInstance() as SampleService;
if Supports(tmpObj,ICallControl,cllCntrl) then
cllCntrl.SetCallContext(callCtx);
hasObjCntrl := Supports(tmpObj,IObjectControl,objCntrl);
if hasObjCntrl then
objCntrl.Activate();
try
returnVal := tmpObj.DuplicateContent(AInitialContent,ARepeatCount);
if Assigned(TObject(returnVal)) then
callCtx.AddObjectToFree(TObject(returnVal));
procName := AFormatter.GetCallProcedureName();
trgName := AFormatter.GetCallTarget();
AFormatter.Clear();
AFormatter.BeginCallResponse(procName,trgName);
AFormatter.Put('result',TypeInfo(TBase64StringRemotable),returnVal);
AFormatter.EndCallResponse();
callCtx := nil;
finally
if hasObjCntrl then
objCntrl.Deactivate();
Self.GetFactory().ReleaseInstance(tmpObj);
end;
end;
constructor TSampleService_ServiceBinder.Create();
begin
inherited Create(GetServiceImplementationRegistry().FindFactory('SampleService'));
RegisterVerbHandler('DuplicateContent',{$IFDEF FPC}@{$ENDIF}DuplicateContentHandler);
end;
{ TSampleService_ServiceBinderFactory }
function TSampleService_ServiceBinderFactory.CreateInstance():IInterface;
begin
Result := FInstance;
end;
constructor TSampleService_ServiceBinderFactory.Create();
begin
FInstance := TSampleService_ServiceBinder.Create() as IInterface;
end;
destructor TSampleService_ServiceBinderFactory.Destroy();
begin
FInstance := nil;
inherited Destroy();
end;
procedure Server_service_RegisterSampleServiceService();
Begin
GetServerServiceRegistry().Register('SampleService',TSampleService_ServiceBinderFactory.Create() as IItemFactory);
End;
initialization
{$i base64sample.wst}
{$IF DECLARED(Register_base64sample_ServiceMetadata)}
Register_base64sample_ServiceMetadata();
{$IFEND}
End.

View File

@ -0,0 +1,56 @@
{
This unit has been produced by ws_helper.
Input unit name : "base64sample".
This unit name : "base64sample_imp".
Date : "07/08/2008 13:17:40".
}
Unit base64sample_imp;
{$IFDEF FPC} {$mode objfpc}{$H+} {$ENDIF}
Interface
Uses SysUtils, Classes,
base_service_intf, server_service_intf, server_service_imputils, base64sample;
Type
TSampleService_ServiceImp=class(TBaseServiceImplementation,SampleService)
Protected
function DuplicateContent(
const AInitialContent : TBase64StringRemotable;
const ARepeatCount : integer
):TBase64StringRemotable;
End;
procedure RegisterSampleServiceImplementationFactory();
Implementation
uses config_objects;
{ TSampleService_ServiceImp implementation }
function TSampleService_ServiceImp.DuplicateContent(
const AInitialContent : TBase64StringRemotable;
const ARepeatCount : integer
):TBase64StringRemotable;
var
i : PtrInt;
Begin
if ( ARepeatCount < 0 ) then
raise Exception.CreateFmt('Invalid "ARepeatCount" value : %d',[ARepeatCount]);
Result := TBase64StringRemotable.Create();
if ( ARepeatCount > 0 ) then begin
Result.BinaryData := AInitialContent.BinaryData;
for i := 2 to ARepeatCount do
Result.BinaryData := Result.BinaryData + AInitialContent.BinaryData;
end;
End;
procedure RegisterSampleServiceImplementationFactory();
Begin
GetServiceImplementationRegistry().Register('SampleService',TImplementationFactory.Create(TSampleService_ServiceImp,wst_GetServiceConfigText('SampleService')) as IServiceImplementationFactory);
End;
End.

View File

@ -0,0 +1,79 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<PathDelim Value="\"/>
<Version Value="6"/>
<General>
<Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/>
<MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
</VersionInfo>
<PublishOptions>
<Version Value="2"/>
<IgnoreBinaries Value="False"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|ppw|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="indylaz"/>
</Item1>
</RequiredPackages>
<Units Count="4">
<Unit0>
<Filename Value="sample.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="sample"/>
</Unit0>
<Unit1>
<Filename Value="base64sample_imp.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="base64sample_imp"/>
</Unit1>
<Unit2>
<Filename Value="base64sample.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="base64sample"/>
</Unit2>
<Unit3>
<Filename Value="base64sample_binder.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="base64sample_binder"/>
</Unit3>
</Units>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
<PathDelim Value="\"/>
<Target>
<Filename Value="sample.exe"/>
</Target>
<SearchPaths>
<IncludeFiles Value="..\..\..\"/>
<OtherUnitFiles Value="..\..\;..\..\..\;..\..\..\wst_rtti_filter\"/>
<UnitOutputDirectory Value="obj"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Other>
<CustomOptions Value="-dINDY_10"/>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
</CONFIG>

View File

@ -0,0 +1,53 @@
// Activate this "define" to logg the messages to the screen
{ $DEFINE WST_LOGGING_CONSOLE}
// Activate this "define" to logg the messages to the file set in "LogFileCompleteName"
{ $DEFINE WST_LOGGING_FILE}
program sample;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils,
server_listener, indy_http_server,
server_service_intf, server_service_soap, metadata_service,
{$IFDEF WST_LOGGING_CONSOLE}
logger_extension,
{$ENDIF}
{$IFDEF WST_LOGGING_FILE}
file_logger_extension,
{$ENDIF}
base64sample, base64sample_binder, base64sample_imp;
var
AppObject : TwstListener;
begin
Server_service_RegisterSoapFormat();
RegisterSampleServiceImplementationFactory();
Server_service_RegisterSampleServiceService();
{$IFDEF WST_LOGGING_FILE}
LogFileCompleteName := Format('.%s%s',[PathDelim,'log.txt']);
GetServiceImplementationRegistry().FindFactory('SampleService').RegisterExtension(['TFileLoggerServiceExtension']);
{$ENDIF}
{$IFDEF WST_LOGGING_CONSOLE}
GetServiceImplementationRegistry().FindFactory('SampleService').RegisterExtension(['TLoggerServiceExtension']);
{$ENDIF}
AppObject := TwstIndyHttpListener.Create('');
try
WriteLn('"Web Service Toolkit" HTTP Server sample listening at:');
WriteLn('');
WriteLn('http://127.0.0.1:8000/');
WriteLn('');
WriteLn('Press enter to quit.');
AppObject.Start();
ReadLn();
finally
FreeAndNil(AppObject);
end;
end.