You've already forked lazarus-ccr
widestring sample
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@770 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
78
wst/trunk/samples/widestring/server/echo_service.pas
Normal file
78
wst/trunk/samples/widestring/server/echo_service.pas
Normal file
@ -0,0 +1,78 @@
|
||||
{
|
||||
This unit has been produced by ws_helper.
|
||||
Input unit name : "echo_service".
|
||||
This unit name : "echo_service".
|
||||
Date : "06/04/2009 17:35:29".
|
||||
}
|
||||
unit echo_service;
|
||||
{$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 = 'uri:echo-service';
|
||||
sUNIT_NAME = 'echo_service';
|
||||
|
||||
type
|
||||
|
||||
|
||||
IEchoService = interface(IInvokable)
|
||||
['{FCD0F68F-3023-46C6-AD09-1DDA4A2989EB}']
|
||||
function EchoWideString(
|
||||
const AValue : WideString
|
||||
):WideString;
|
||||
end;
|
||||
|
||||
procedure Register_echo_service_ServiceMetadata();
|
||||
|
||||
Implementation
|
||||
uses metadata_repository, record_rtti, wst_types;
|
||||
|
||||
|
||||
procedure Register_echo_service_ServiceMetadata();
|
||||
var
|
||||
mm : IModuleMetadataMngr;
|
||||
begin
|
||||
mm := GetModuleMetadataMngr();
|
||||
mm.SetRepositoryNameSpace(sUNIT_NAME, sNAME_SPACE);
|
||||
mm.SetServiceCustomData(
|
||||
sUNIT_NAME,
|
||||
'IEchoService',
|
||||
'FORMAT_Style',
|
||||
'rpc'
|
||||
);
|
||||
mm.SetOperationCustomData(
|
||||
sUNIT_NAME,
|
||||
'IEchoService',
|
||||
'EchoWideString',
|
||||
'_E_N_',
|
||||
'EchoWideString'
|
||||
);
|
||||
mm.SetOperationCustomData(
|
||||
sUNIT_NAME,
|
||||
'IEchoService',
|
||||
'EchoWideString',
|
||||
'FORMAT_Input_EncodingStyle',
|
||||
'literal'
|
||||
);
|
||||
mm.SetOperationCustomData(
|
||||
sUNIT_NAME,
|
||||
'IEchoService',
|
||||
'EchoWideString',
|
||||
'FORMAT_OutputEncodingStyle',
|
||||
'literal'
|
||||
);
|
||||
end;
|
||||
|
||||
|
||||
initialization
|
||||
|
||||
|
||||
|
||||
End.
|
5
wst/trunk/samples/widestring/server/echo_service.wst
Normal file
5
wst/trunk/samples/widestring/server/echo_service.wst
Normal file
@ -0,0 +1,5 @@
|
||||
GetWSTResourceManager().AddResource('ECHO_SERVICE',
|
||||
#0#0#0#20'WST_METADATA_0.2.2.0'#0#0#0#12'echo_service'#1#0#0#0#12'IEchoServi'
|
||||
+'ce'#1#0#0#0#14'EchoWideString'#2#0#0#0#6'AValue'#0#0#0#10'WideString'#0#0#0
|
||||
+#0#0#0#0#1#0#0#0#6'Result'#0#0#0#10'WideString'#0#0#0#0#0#0#0#3''
|
||||
);
|
119
wst/trunk/samples/widestring/server/echo_service_binder.pas
Normal file
119
wst/trunk/samples/widestring/server/echo_service_binder.pas
Normal file
@ -0,0 +1,119 @@
|
||||
{
|
||||
This unit has been produced by ws_helper.
|
||||
Input unit name : "echo_service".
|
||||
This unit name : "echo_service_binder".
|
||||
Date : "06/04/2009 17:35:29".
|
||||
}
|
||||
unit echo_service_binder;
|
||||
{$IFDEF FPC} {$mode objfpc}{$H+} {$ENDIF}
|
||||
interface
|
||||
|
||||
uses SysUtils, Classes, base_service_intf, server_service_intf, echo_service;
|
||||
|
||||
type
|
||||
|
||||
|
||||
TEchoService_ServiceBinder = class(TBaseServiceBinder)
|
||||
protected
|
||||
procedure EchoWideStringHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
||||
public
|
||||
constructor Create();
|
||||
end;
|
||||
|
||||
TEchoService_ServiceBinderFactory = class(TInterfacedObject,IItemFactory)
|
||||
private
|
||||
FInstance : IInterface;
|
||||
protected
|
||||
function CreateInstance():IInterface;
|
||||
public
|
||||
constructor Create();
|
||||
destructor Destroy();override;
|
||||
end;
|
||||
|
||||
procedure Server_service_RegisterEchoServiceService();
|
||||
|
||||
Implementation
|
||||
uses TypInfo, wst_resources_imp,metadata_repository;
|
||||
|
||||
{ TEchoService_ServiceBinder implementation }
|
||||
procedure TEchoService_ServiceBinder.EchoWideStringHandler(AFormatter : IFormatterResponse; AContext : ICallContext);
|
||||
var
|
||||
cllCntrl : ICallControl;
|
||||
objCntrl : IObjectControl;
|
||||
hasObjCntrl : Boolean;
|
||||
tmpObj : IEchoService;
|
||||
callCtx : ICallContext;
|
||||
locStrPrmName : string;
|
||||
procName,trgName : string;
|
||||
AValue : WideString;
|
||||
returnVal : WideString;
|
||||
begin
|
||||
callCtx := AContext;
|
||||
|
||||
locStrPrmName := 'AValue'; AFormatter.Get(TypeInfo(WideString),locStrPrmName,AValue);
|
||||
|
||||
tmpObj := Self.GetFactory().CreateInstance() as IEchoService;
|
||||
if Supports(tmpObj,ICallControl,cllCntrl) then
|
||||
cllCntrl.SetCallContext(callCtx);
|
||||
hasObjCntrl := Supports(tmpObj,IObjectControl,objCntrl);
|
||||
if hasObjCntrl then
|
||||
objCntrl.Activate();
|
||||
try
|
||||
returnVal := tmpObj.EchoWideString(AValue);
|
||||
|
||||
procName := AFormatter.GetCallProcedureName();
|
||||
trgName := AFormatter.GetCallTarget();
|
||||
AFormatter.Clear();
|
||||
AFormatter.BeginCallResponse(procName,trgName);
|
||||
AFormatter.Put('result',TypeInfo(WideString),returnVal);
|
||||
AFormatter.EndCallResponse();
|
||||
|
||||
callCtx := nil;
|
||||
finally
|
||||
if hasObjCntrl then
|
||||
objCntrl.Deactivate();
|
||||
Self.GetFactory().ReleaseInstance(tmpObj);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
constructor TEchoService_ServiceBinder.Create();
|
||||
begin
|
||||
inherited Create(GetServiceImplementationRegistry().FindFactory('IEchoService'));
|
||||
RegisterVerbHandler('EchoWideString',{$IFDEF FPC}@{$ENDIF}EchoWideStringHandler);
|
||||
end;
|
||||
|
||||
|
||||
{ TEchoService_ServiceBinderFactory }
|
||||
|
||||
function TEchoService_ServiceBinderFactory.CreateInstance():IInterface;
|
||||
begin
|
||||
Result := FInstance;
|
||||
end;
|
||||
|
||||
constructor TEchoService_ServiceBinderFactory.Create();
|
||||
begin
|
||||
FInstance := TEchoService_ServiceBinder.Create() as IInterface;
|
||||
end;
|
||||
|
||||
destructor TEchoService_ServiceBinderFactory.Destroy();
|
||||
begin
|
||||
FInstance := nil;
|
||||
inherited Destroy();
|
||||
end;
|
||||
|
||||
|
||||
procedure Server_service_RegisterEchoServiceService();
|
||||
Begin
|
||||
GetServerServiceRegistry().Register('IEchoService',TEchoService_ServiceBinderFactory.Create() as IItemFactory);
|
||||
End;
|
||||
|
||||
initialization
|
||||
|
||||
{$i echo_service.wst}
|
||||
|
||||
{$IF DECLARED(Register_echo_service_ServiceMetadata)}
|
||||
Register_echo_service_ServiceMetadata();
|
||||
{$IFEND}
|
||||
|
||||
End.
|
45
wst/trunk/samples/widestring/server/echo_service_imp.pas
Normal file
45
wst/trunk/samples/widestring/server/echo_service_imp.pas
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
This unit has been produced by ws_helper.
|
||||
Input unit name : "echo_service".
|
||||
This unit name : "echo_service_imp".
|
||||
Date : "06/04/2009 17:25:42".
|
||||
}
|
||||
Unit echo_service_imp;
|
||||
{$IFDEF FPC} {$mode objfpc}{$H+} {$ENDIF}
|
||||
Interface
|
||||
|
||||
Uses SysUtils, Classes,
|
||||
base_service_intf, server_service_intf, server_service_imputils, echo_service;
|
||||
|
||||
Type
|
||||
|
||||
|
||||
TEchoService_ServiceImp=class(TBaseServiceImplementation,IEchoService)
|
||||
Protected
|
||||
function EchoWideString(
|
||||
const AValue : WideString
|
||||
):WideString;
|
||||
End;
|
||||
|
||||
|
||||
procedure RegisterEchoServiceImplementationFactory();
|
||||
|
||||
Implementation
|
||||
uses config_objects;
|
||||
|
||||
{ TEchoService_ServiceImp implementation }
|
||||
function TEchoService_ServiceImp.EchoWideString(
|
||||
const AValue : WideString
|
||||
):WideString;
|
||||
Begin
|
||||
Result := AValue + AValue;
|
||||
End;
|
||||
|
||||
|
||||
|
||||
procedure RegisterEchoServiceImplementationFactory();
|
||||
Begin
|
||||
GetServiceImplementationRegistry().Register('IEchoService',TImplementationFactory.Create(TEchoService_ServiceImp,wst_GetServiceConfigText('IEchoService')) as IServiceImplementationFactory);
|
||||
End;
|
||||
|
||||
End.
|
85
wst/trunk/samples/widestring/server/ws_server.lpi
Normal file
85
wst/trunk/samples/widestring/server/ws_server.lpi
Normal file
@ -0,0 +1,85 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<SessionStorage Value="InProjectDir"/>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Icon Value="0"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
</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="2">
|
||||
<Item1>
|
||||
<PackageName Value="wst_indy"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="wst_core"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="4">
|
||||
<Unit0>
|
||||
<Filename Value="ws_server.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ws_server"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="echo_service_imp.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="echo_service_imp"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="echo_service.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="echo_service"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="echo_service_binder.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="echo_service_binder"/>
|
||||
</Unit3>
|
||||
</Units>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="ws_server"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)\"/>
|
||||
<UnitOutputDirectory Value="obj"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<CStyleOperator Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Other>
|
||||
<CustomOptions Value="-dINDY_10
|
||||
"/>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
</CONFIG>
|
29
wst/trunk/samples/widestring/server/ws_server.pas
Normal file
29
wst/trunk/samples/widestring/server/ws_server.pas
Normal file
@ -0,0 +1,29 @@
|
||||
program ws_server;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}
|
||||
cthreads, cwstring,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils,
|
||||
server_listener, server_service_intf, server_service_soap, indy_http_server,
|
||||
echo_service, echo_service_binder, echo_service_imp;
|
||||
|
||||
var
|
||||
appObj : TwstListener;
|
||||
begin
|
||||
Server_service_RegisterSoapFormat();
|
||||
RegisterEchoServiceImplementationFactory();
|
||||
Server_service_RegisterEchoServiceService();
|
||||
appObj := TwstIndyHttpListener.Create();
|
||||
try
|
||||
appObj.Start();
|
||||
WriteLn('WST Echo-Service sample. Hit any <return> to stop.');
|
||||
ReadLn;
|
||||
appObj.Stop();
|
||||
finally
|
||||
appObj.Free();
|
||||
end;
|
||||
end.
|
||||
|
Reference in New Issue
Block a user