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:
parent
3e8d4b2e0b
commit
d673332bf8
78
wst/trunk/samples/widestring/client/echo_service.pas
Normal file
78
wst/trunk/samples/widestring/client/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:57:59".
|
||||
}
|
||||
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/client/echo_service.wst
Normal file
5
wst/trunk/samples/widestring/client/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''
|
||||
);
|
81
wst/trunk/samples/widestring/client/echo_service_proxy.pas
Normal file
81
wst/trunk/samples/widestring/client/echo_service_proxy.pas
Normal file
@ -0,0 +1,81 @@
|
||||
{
|
||||
This unit has been produced by ws_helper.
|
||||
Input unit name : "echo_service".
|
||||
This unit name : "echo_service_proxy".
|
||||
Date : "06/04/2009 17:57:59".
|
||||
}
|
||||
|
||||
Unit echo_service_proxy;
|
||||
{$IFDEF FPC} {$mode objfpc}{$H+} {$ENDIF}
|
||||
Interface
|
||||
|
||||
Uses SysUtils, Classes, TypInfo, base_service_intf, service_intf, echo_service;
|
||||
|
||||
Type
|
||||
|
||||
|
||||
TEchoService_Proxy=class(TBaseProxy,IEchoService)
|
||||
Protected
|
||||
class function GetServiceType() : PTypeInfo;override;
|
||||
function EchoWideString(
|
||||
const AValue : WideString
|
||||
):WideString;
|
||||
End;
|
||||
|
||||
Function wst_CreateInstance_IEchoService(const AFormat : string = 'SOAP:'; const ATransport : string = 'HTTP:'; const AAddress : string = ''):IEchoService;
|
||||
|
||||
Implementation
|
||||
uses wst_resources_imp, metadata_repository;
|
||||
|
||||
|
||||
Function wst_CreateInstance_IEchoService(const AFormat : string; const ATransport : string; const AAddress : string):IEchoService;
|
||||
Var
|
||||
locAdr : string;
|
||||
Begin
|
||||
locAdr := AAddress;
|
||||
if ( locAdr = '' ) then
|
||||
locAdr := GetServiceDefaultAddress(TypeInfo(IEchoService));
|
||||
Result := TEchoService_Proxy.Create('IEchoService',AFormat+GetServiceDefaultFormatProperties(TypeInfo(IEchoService)),ATransport + 'address=' + locAdr);
|
||||
End;
|
||||
|
||||
{ TEchoService_Proxy implementation }
|
||||
|
||||
class function TEchoService_Proxy.GetServiceType() : PTypeInfo;
|
||||
begin
|
||||
result := TypeInfo(IEchoService);
|
||||
end;
|
||||
|
||||
function TEchoService_Proxy.EchoWideString(
|
||||
const AValue : WideString
|
||||
):WideString;
|
||||
Var
|
||||
locSerializer : IFormatterClient;
|
||||
locCallContext : ICallContext;
|
||||
locStrPrmName : string;
|
||||
Begin
|
||||
locCallContext := Self as ICallContext;
|
||||
locSerializer := GetSerializer();
|
||||
Try
|
||||
locSerializer.BeginCall('EchoWideString', GetTarget(),locCallContext);
|
||||
locSerializer.Put('AValue', TypeInfo(WideString), AValue);
|
||||
locSerializer.EndCall();
|
||||
|
||||
MakeCall();
|
||||
|
||||
locSerializer.BeginCallRead(locCallContext);
|
||||
locStrPrmName := 'result';
|
||||
locSerializer.Get(TypeInfo(WideString), locStrPrmName, Result);
|
||||
|
||||
Finally
|
||||
locSerializer.Clear();
|
||||
End;
|
||||
End;
|
||||
|
||||
|
||||
initialization
|
||||
{$i echo_service.wst}
|
||||
|
||||
{$IF DECLARED(Register_echo_service_ServiceMetadata)}
|
||||
Register_echo_service_ServiceMetadata();
|
||||
{$IFEND}
|
||||
End.
|
287
wst/trunk/samples/widestring/client/ws_client.lpi
Normal file
287
wst/trunk/samples/widestring/client/ws_client.lpi
Normal file
@ -0,0 +1,287 @@
|
||||
<?xml version="1.0"?>
|
||||
<CONFIG>
|
||||
<ProjectOptions>
|
||||
<PathDelim Value="\"/>
|
||||
<Version Value="7"/>
|
||||
<General>
|
||||
<Flags>
|
||||
<MainUnitHasUsesSectionForAllUnits Value="False"/>
|
||||
<MainUnitHasCreateFormStatements Value="False"/>
|
||||
<MainUnitHasTitleStatement Value="False"/>
|
||||
</Flags>
|
||||
<MainUnit Value="0"/>
|
||||
<TargetFileExt Value=".exe"/>
|
||||
<Icon Value="0"/>
|
||||
<UseXPManifest Value="True"/>
|
||||
<ActiveEditorIndexAtStart Value="0"/>
|
||||
</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_synapse"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<PackageName Value="wst_core"/>
|
||||
</Item2>
|
||||
</RequiredPackages>
|
||||
<Units Count="10">
|
||||
<Unit0>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="ws_client"/>
|
||||
<CursorPos X="13" Y="8"/>
|
||||
<TopLine Value="1"/>
|
||||
<EditorIndex Value="0"/>
|
||||
<UsageCount Value="29"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit0>
|
||||
<Unit1>
|
||||
<Filename Value="echo_service_proxy.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="echo_service_proxy"/>
|
||||
<CursorPos X="3" Y="35"/>
|
||||
<TopLine Value="31"/>
|
||||
<EditorIndex Value="4"/>
|
||||
<UsageCount Value="29"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit1>
|
||||
<Unit2>
|
||||
<Filename Value="echo_service.pas"/>
|
||||
<IsPartOfProject Value="True"/>
|
||||
<UnitName Value="echo_service"/>
|
||||
<CursorPos X="3" Y="25"/>
|
||||
<TopLine Value="14"/>
|
||||
<EditorIndex Value="6"/>
|
||||
<UsageCount Value="29"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit2>
|
||||
<Unit3>
|
||||
<Filename Value="..\..\..\synapse_tcp_protocol.pas"/>
|
||||
<UnitName Value="synapse_tcp_protocol"/>
|
||||
<CursorPos X="1" Y="74"/>
|
||||
<TopLine Value="69"/>
|
||||
<EditorIndex Value="3"/>
|
||||
<UsageCount Value="15"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit3>
|
||||
<Unit4>
|
||||
<Filename Value="..\..\..\soap_formatter.pas"/>
|
||||
<UnitName Value="soap_formatter"/>
|
||||
<CursorPos X="1" Y="235"/>
|
||||
<TopLine Value="224"/>
|
||||
<EditorIndex Value="2"/>
|
||||
<UsageCount Value="15"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit4>
|
||||
<Unit5>
|
||||
<Filename Value="..\..\..\service_intf.pas"/>
|
||||
<UnitName Value="service_intf"/>
|
||||
<CursorPos X="1" Y="221"/>
|
||||
<TopLine Value="210"/>
|
||||
<EditorIndex Value="5"/>
|
||||
<UsageCount Value="14"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit5>
|
||||
<Unit6>
|
||||
<Filename Value="E:\lazarus26r2.2.2.2\fpc\2.2.2\source\rtl\objpas\sysutils\sysutilh.inc"/>
|
||||
<CursorPos X="4" Y="210"/>
|
||||
<TopLine Value="198"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit6>
|
||||
<Unit7>
|
||||
<Filename Value="E:\lazarus26r2.2.2.2\fpc\2.2.2\source\rtl\win32\system.pp"/>
|
||||
<UnitName Value="System"/>
|
||||
<CursorPos X="25" Y="41"/>
|
||||
<TopLine Value="32"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit7>
|
||||
<Unit8>
|
||||
<Filename Value="E:\lazarus26r2.2.2.2\fpc\2.2.2\source\rtl\inc\wstringh.inc"/>
|
||||
<CursorPos X="20" Y="87"/>
|
||||
<TopLine Value="74"/>
|
||||
<EditorIndex Value="1"/>
|
||||
<UsageCount Value="14"/>
|
||||
<Loaded Value="True"/>
|
||||
</Unit8>
|
||||
<Unit9>
|
||||
<Filename Value="E:\lazarus26r2.2.2.2\fpc\2.2.2\source\rtl\inc\systemh.inc"/>
|
||||
<CursorPos X="3" Y="234"/>
|
||||
<TopLine Value="223"/>
|
||||
<UsageCount Value="9"/>
|
||||
</Unit9>
|
||||
</Units>
|
||||
<JumpHistory Count="30" HistoryIndex="29">
|
||||
<Position1>
|
||||
<Filename Value="..\..\..\service_intf.pas"/>
|
||||
<Caret Line="220" Column="1" TopLine="209"/>
|
||||
</Position1>
|
||||
<Position2>
|
||||
<Filename Value="..\..\..\service_intf.pas"/>
|
||||
<Caret Line="436" Column="1" TopLine="425"/>
|
||||
</Position2>
|
||||
<Position3>
|
||||
<Filename Value="..\..\..\service_intf.pas"/>
|
||||
<Caret Line="437" Column="1" TopLine="426"/>
|
||||
</Position3>
|
||||
<Position4>
|
||||
<Filename Value="..\..\..\service_intf.pas"/>
|
||||
<Caret Line="438" Column="1" TopLine="427"/>
|
||||
</Position4>
|
||||
<Position5>
|
||||
<Filename Value="..\..\..\service_intf.pas"/>
|
||||
<Caret Line="221" Column="1" TopLine="210"/>
|
||||
</Position5>
|
||||
<Position6>
|
||||
<Filename Value="..\..\..\soap_formatter.pas"/>
|
||||
<Caret Line="225" Column="13" TopLine="206"/>
|
||||
</Position6>
|
||||
<Position7>
|
||||
<Filename Value="..\..\..\soap_formatter.pas"/>
|
||||
<Caret Line="220" Column="1" TopLine="209"/>
|
||||
</Position7>
|
||||
<Position8>
|
||||
<Filename Value="..\..\..\synapse_tcp_protocol.pas"/>
|
||||
<Caret Line="106" Column="1" TopLine="95"/>
|
||||
</Position8>
|
||||
<Position9>
|
||||
<Filename Value="..\..\..\synapse_tcp_protocol.pas"/>
|
||||
<Caret Line="107" Column="1" TopLine="96"/>
|
||||
</Position9>
|
||||
<Position10>
|
||||
<Filename Value="..\..\..\synapse_tcp_protocol.pas"/>
|
||||
<Caret Line="108" Column="1" TopLine="97"/>
|
||||
</Position10>
|
||||
<Position11>
|
||||
<Filename Value="..\..\..\soap_formatter.pas"/>
|
||||
<Caret Line="235" Column="1" TopLine="224"/>
|
||||
</Position11>
|
||||
<Position12>
|
||||
<Filename Value="..\..\..\synapse_tcp_protocol.pas"/>
|
||||
<Caret Line="134" Column="1" TopLine="123"/>
|
||||
</Position12>
|
||||
<Position13>
|
||||
<Filename Value="..\..\..\synapse_tcp_protocol.pas"/>
|
||||
<Caret Line="74" Column="1" TopLine="63"/>
|
||||
</Position13>
|
||||
<Position14>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="18" Column="72" TopLine="6"/>
|
||||
</Position14>
|
||||
<Position15>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="27" Column="44" TopLine="8"/>
|
||||
</Position15>
|
||||
<Position16>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="30" Column="26" TopLine="15"/>
|
||||
</Position16>
|
||||
<Position17>
|
||||
<Filename Value="E:\lazarus26r2.2.2.2\fpc\2.2.2\source\rtl\inc\wstringh.inc"/>
|
||||
<Caret Line="85" Column="52" TopLine="74"/>
|
||||
</Position17>
|
||||
<Position18>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="27" Column="19" TopLine="6"/>
|
||||
</Position18>
|
||||
<Position19>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="24" Column="25" TopLine="14"/>
|
||||
</Position19>
|
||||
<Position20>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="23" Column="5" TopLine="15"/>
|
||||
</Position20>
|
||||
<Position21>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="32" Column="41" TopLine="22"/>
|
||||
</Position21>
|
||||
<Position22>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="33" Column="1" TopLine="22"/>
|
||||
</Position22>
|
||||
<Position23>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="16" Column="1" TopLine="11"/>
|
||||
</Position23>
|
||||
<Position24>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="32" Column="1" TopLine="21"/>
|
||||
</Position24>
|
||||
<Position25>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="33" Column="39" TopLine="22"/>
|
||||
</Position25>
|
||||
<Position26>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="37" Column="9" TopLine="22"/>
|
||||
</Position26>
|
||||
<Position27>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="33" Column="1" TopLine="22"/>
|
||||
</Position27>
|
||||
<Position28>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="13" Column="30" TopLine="2"/>
|
||||
</Position28>
|
||||
<Position29>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="15" Column="3" TopLine="1"/>
|
||||
</Position29>
|
||||
<Position30>
|
||||
<Filename Value="ws_client.pas"/>
|
||||
<Caret Line="11" Column="4" TopLine="11"/>
|
||||
</Position30>
|
||||
</JumpHistory>
|
||||
</ProjectOptions>
|
||||
<CompilerOptions>
|
||||
<Version Value="8"/>
|
||||
<PathDelim Value="\"/>
|
||||
<Target>
|
||||
<Filename Value="ws_client"/>
|
||||
</Target>
|
||||
<SearchPaths>
|
||||
<IncludeFiles Value="$(ProjOutDir)\"/>
|
||||
<UnitOutputDirectory Value="obj"/>
|
||||
</SearchPaths>
|
||||
<Parsing>
|
||||
<SyntaxOptions>
|
||||
<CStyleOperator Value="False"/>
|
||||
</SyntaxOptions>
|
||||
</Parsing>
|
||||
<Other>
|
||||
<CompilerPath Value="$(CompPath)"/>
|
||||
</Other>
|
||||
</CompilerOptions>
|
||||
<Debugging>
|
||||
<Watches Count="1">
|
||||
<Item1>
|
||||
<Expression Value="FPort"/>
|
||||
</Item1>
|
||||
</Watches>
|
||||
<Exceptions Count="3">
|
||||
<Item1>
|
||||
<Name Value="EAbort"/>
|
||||
</Item1>
|
||||
<Item2>
|
||||
<Name Value="ECodetoolError"/>
|
||||
</Item2>
|
||||
<Item3>
|
||||
<Name Value="EFOpenError"/>
|
||||
</Item3>
|
||||
</Exceptions>
|
||||
</Debugging>
|
||||
</CONFIG>
|
48
wst/trunk/samples/widestring/client/ws_client.pas
Normal file
48
wst/trunk/samples/widestring/client/ws_client.pas
Normal file
@ -0,0 +1,48 @@
|
||||
program ws_client;
|
||||
|
||||
{$mode objfpc}{$H+}
|
||||
|
||||
uses
|
||||
{$IFDEF UNIX}
|
||||
cthreads, cwstring,
|
||||
{$ENDIF}
|
||||
Classes, SysUtils,
|
||||
service_intf, soap_formatter, synapse_http_protocol,
|
||||
echo_service, echo_service_proxy;
|
||||
|
||||
const
|
||||
utf16_bom : array[0..1] of Byte = ($FF, $FE);
|
||||
binary_buffer : array[0..7] of Word = ($E9, $E9, $E8, $E8, $E7, $E7, $E0, $E0);
|
||||
|
||||
var
|
||||
locService : IEchoService;
|
||||
ws, wsres : WideString;
|
||||
ms : TMemoryStream;
|
||||
c : Integer;
|
||||
begin
|
||||
SYNAPSE_RegisterHTTP_Transport();
|
||||
|
||||
locService := wst_CreateInstance_IEchoService('SOAP:','HTTP:','http://127.0.0.1:8000/services/IEchoService');
|
||||
|
||||
WriteLn('WST WideString Sample - Client');
|
||||
|
||||
ms := TMemoryStream.Create();
|
||||
try
|
||||
SetLength(ws, Length(binary_buffer) );
|
||||
Move(binary_buffer[0], Pointer(ws)^, Length(binary_buffer) * 2);
|
||||
|
||||
|
||||
ms.Write(utf16_bom,SizeOf(utf16_bom));
|
||||
ms.Write(Pointer(ws)^, ( Length(ws) * SizeOf(WideChar) ) );
|
||||
ms.SaveToFile(ExpandFileName('.' + PathDelim + 'input.widestring'));
|
||||
|
||||
wsres := locService.EchoWideString(ws);
|
||||
ms.Clear();
|
||||
ms.Write(utf16_bom,SizeOf(utf16_bom));
|
||||
ms.Write(Pointer(wsres)^, ( Length(wsres) * SizeOf(WideChar) ) );
|
||||
ms.SaveToFile(ExpandFileName('.' + PathDelim + 'output.widestring'));
|
||||
finally
|
||||
ms.Free();
|
||||
end;
|
||||
end.
|
||||
|
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.
|
||||
|
Loading…
Reference in New Issue
Block a user