use TByteDynArray for buffer instead of string :

correction for tcp transport
  correction for library transport

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@809 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa
2009-05-25 16:13:54 +00:00
parent 4d76fe4edd
commit 13d1e675e6
15 changed files with 121 additions and 82 deletions

View File

@ -449,7 +449,7 @@ begin
i := Length(AData); i := Length(AData);
WriteInt32S(i); WriteInt32S(i);
if ( i > 0 ) then if ( i > 0 ) then
FStream.Write(AData[1],i); FStream.Write(AData[0],i);
end; end;
{$IFDEF WST_UNICODESTRING} {$IFDEF WST_UNICODESTRING}
@ -637,7 +637,7 @@ begin
i := ReadInt32S(); i := ReadInt32S();
SetLength(Result,i); SetLength(Result,i);
if ( i > 0 ) then if ( i > 0 ) then
FStream.ReadBuffer(Result[1],i); FStream.ReadBuffer(Result[0],i);
end; end;
{$IFDEF WST_UNICODESTRING} {$IFDEF WST_UNICODESTRING}

View File

@ -125,7 +125,7 @@ begin
wrtr.WriteAnsiStr(Self.Format); wrtr.WriteAnsiStr(Self.Format);
SetLength(binBuff,ARequest.Size); SetLength(binBuff,ARequest.Size);
ARequest.Position := 0; ARequest.Position := 0;
ARequest.Read(binBuff[1],Length(binBuff)); ARequest.Read(binBuff[0],Length(binBuff));
wrtr.WriteBinary(binBuff); wrtr.WriteBinary(binBuff);
buffStream.Position := 0; buffStream.Position := 0;
wrtr.WriteInt32S(buffStream.Size-4); wrtr.WriteInt32S(buffStream.Size-4);

View File

@ -163,13 +163,9 @@ begin
frmt := rdr.ReadAnsiStr(); frmt := rdr.ReadAnsiStr();
buff := rdr.ReadBinary(); buff := rdr.ReadBinary();
{$IFDEF WST_DBG}
WriteLn(buff);
{$ENDIF}
rdr := nil; rdr := nil;
locInStream.Size := 0; locInStream.Size := 0;
locInStream.Write(buff[1],Length(buff)); locInStream.Write(buff[0],Length(buff));
SetLength(buff,0); SetLength(buff,0);
locInStream.Position := 0; locInStream.Position := 0;
rqst := TRequestBuffer.Create(trgt,ctntyp,locInStream,locOutStream,frmt); rqst := TRequestBuffer.Create(trgt,ctntyp,locInStream,locOutStream,frmt);
@ -179,7 +175,7 @@ begin
i := locOutStream.Size; i := locOutStream.Size;
SetLength(buff,i); SetLength(buff,i);
locOutStream.Position := 0; locOutStream.Position := 0;
locOutStream.Read(buff[1],i); locOutStream.Read(buff[0],i);
locOutStream.Size := 0; locOutStream.Size := 0;
wrtr := CreateBinaryWriter(locOutStream); wrtr := CreateBinaryWriter(locOutStream);
wrtr.WriteBinary(buff); wrtr.WriteBinary(buff);

View File

@ -105,9 +105,10 @@ procedure TLIBTransport.SendAndReceive(ARequest, AResponse: TStream);
Var Var
wrtr : IDataStore; wrtr : IDataStore;
buffStream : TMemoryStream; buffStream : TMemoryStream;
strBuff : TBinaryString; buff : TByteDynArray;
intfBuffer : IwstStream; intfBuffer : IwstStream;
bl : LongInt; bl : LongInt;
errorStrBuffer : ansistring;
{$IFDEF WST_DBG} {$IFDEF WST_DBG}
s : TBinaryString; s : TBinaryString;
i : Int64; i : Int64;
@ -121,23 +122,19 @@ begin
wrtr.WriteAnsiStr(Target); wrtr.WriteAnsiStr(Target);
wrtr.WriteAnsiStr(ContentType); wrtr.WriteAnsiStr(ContentType);
wrtr.WriteAnsiStr(Self.Format); wrtr.WriteAnsiStr(Self.Format);
SetLength(strBuff,ARequest.Size); SetLength(buff,ARequest.Size);
ARequest.Position := 0; ARequest.Position := 0;
ARequest.Read(strBuff[1],Length(strBuff)); ARequest.Read(buff[0],Length(buff));
{$IFDEF WST_DBG} wrtr.WriteBinary(buff);
if IsConsole then
WriteLn(strBuff);
{$ENDIF WST_DBG}
wrtr.WriteAnsiStr(strBuff);
buffStream.Position := 0; buffStream.Position := 0;
wrtr.WriteInt32S(buffStream.Size-4); wrtr.WriteInt32S(buffStream.Size-4);
buffStream.Position := 0; buffStream.Position := 0;
intfBuffer := TwstStream.Create(buffStream); intfBuffer := TwstStream.Create(buffStream);
bl := MAX_ERR_LEN; bl := MAX_ERR_LEN;
strBuff := StringOfChar(#0,bl); errorStrBuffer := StringOfChar(#0,bl);
if ( FHandler(intfBuffer,Pointer(strBuff),bl) <> RET_OK ) then if ( FHandler(intfBuffer,Pointer(errorStrBuffer),bl) <> RET_OK ) then
raise Exception.Create(strBuff); raise Exception.Create(errorStrBuffer);
buffStream.Position := 0; buffStream.Position := 0;
AResponse.Size := 0; AResponse.Size := 0;

View File

@ -51,7 +51,8 @@ function wstHandleRequest(
end; end;
Var Var
buff, trgt,ctntyp, frmt : TBinaryString; trgt,ctntyp, frmt : TBinaryString;
binBuff : TByteDynArray;
rqst : IRequestBuffer; rqst : IRequestBuffer;
rdr : IDataStoreReader; rdr : IDataStoreReader;
inStream, bufStream : TMemoryStream; inStream, bufStream : TMemoryStream;
@ -82,12 +83,12 @@ begin
trgt := rdr.ReadAnsiStr(); trgt := rdr.ReadAnsiStr();
ctntyp := rdr.ReadAnsiStr(); ctntyp := rdr.ReadAnsiStr();
frmt := rdr.ReadAnsiStr(); frmt := rdr.ReadAnsiStr();
buff := rdr.ReadAnsiStr(); binBuff := rdr.ReadBinary();
rdr := nil; rdr := nil;
bufStream.Size := 0; bufStream.Size := 0;
bufStream.Position := 0; bufStream.Position := 0;
inStream.Write(buff[1],Length(buff)); inStream.Write(binBuff[0],Length(binBuff));
SetLength(buff,0); SetLength(binBuff,0);
inStream.Position := 0; inStream.Position := 0;
rqst := TRequestBuffer.Create(trgt,ctntyp,inStream,bufStream,frmt); rqst := TRequestBuffer.Create(trgt,ctntyp,inStream,bufStream,frmt);
HandleServiceRequest(rqst); HandleServiceRequest(rqst);

View File

@ -45,7 +45,7 @@ type
Modifier : TOperationParamFlag; Modifier : TOperationParamFlag;
end; end;
PServiceOperation = ^TServiceOperation; PServiceOperation = ^TServiceOperation;
TServiceOperation = record TServiceOperation = record
Name : ShortString; Name : ShortString;
ParamsCount : Byte; ParamsCount : Byte;
@ -279,6 +279,8 @@ begin
end; end;
Freemem(AService^.Operations, k * SizeOf(TServiceOperation) ); Freemem(AService^.Operations, k * SizeOf(TServiceOperation) );
AService^.Operations := nil; AService^.Operations := nil;
end;
if ( AService^.Properties <> nil ) then begin
ClearProperties(AService^.Properties); ClearProperties(AService^.Properties);
AService^.Properties := nil; AService^.Properties := nil;
end; end;

View File

@ -2,11 +2,13 @@
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="6"/> <Version Value="7"/>
<General> <General>
<Flags>
<LRSInOutputDirectory Value="False"/>
</Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<IconPath Value=".\"/>
<TargetFileExt Value=".exe"/> <TargetFileExt Value=".exe"/>
</General> </General>
<VersionInfo> <VersionInfo>
@ -34,7 +36,7 @@
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="5"/> <Version Value="8"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Target> <Target>
<Filename Value="lib_server.dll"/> <Filename Value="lib_server.dll"/>
@ -44,9 +46,6 @@
<OtherUnitFiles Value="..\;..\..\;..\..\wst_rtti_filter\"/> <OtherUnitFiles Value="..\;..\..\;..\..\wst_rtti_filter\"/>
<UnitOutputDirectory Value="obj"/> <UnitOutputDirectory Value="obj"/>
</SearchPaths> </SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Linking> <Linking>
<Debugging> <Debugging>
<UseLineInfoUnit Value="False"/> <UseLineInfoUnit Value="False"/>

View File

@ -2,16 +2,16 @@
<CONFIG> <CONFIG>
<ProjectOptions> <ProjectOptions>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Version Value="6"/> <Version Value="7"/>
<General> <General>
<Flags> <Flags>
<MainUnitHasUsesSectionForAllUnits Value="False"/> <MainUnitHasUsesSectionForAllUnits Value="False"/>
<MainUnitHasCreateFormStatements Value="False"/> <MainUnitHasCreateFormStatements Value="False"/>
<MainUnitHasTitleStatement Value="False"/> <MainUnitHasTitleStatement Value="False"/>
<LRSInOutputDirectory Value="False"/>
</Flags> </Flags>
<SessionStorage Value="InProjectDir"/> <SessionStorage Value="InProjectDir"/>
<MainUnit Value="0"/> <MainUnit Value="0"/>
<IconPath Value=".\"/>
<TargetFileExt Value=".exe"/> <TargetFileExt Value=".exe"/>
</General> </General>
<VersionInfo> <VersionInfo>
@ -28,6 +28,11 @@
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="1">
<Item1>
<PackageName Value="wst_indy"/>
</Item1>
</RequiredPackages>
<Units Count="4"> <Units Count="4">
<Unit0> <Unit0>
<Filename Value="tcp_server.pas"/> <Filename Value="tcp_server.pas"/>
@ -52,7 +57,7 @@
</Units> </Units>
</ProjectOptions> </ProjectOptions>
<CompilerOptions> <CompilerOptions>
<Version Value="5"/> <Version Value="8"/>
<PathDelim Value="\"/> <PathDelim Value="\"/>
<Target> <Target>
<Filename Value="tcp_server.exe"/> <Filename Value="tcp_server.exe"/>
@ -69,10 +74,8 @@
<UseAnsiStrings Value="True"/> <UseAnsiStrings Value="True"/>
</SyntaxOptions> </SyntaxOptions>
</Parsing> </Parsing>
<CodeGeneration>
<Generate Value="Faster"/>
</CodeGeneration>
<Other> <Other>
<CustomOptions Value="-dINDY_10"/>
<CompilerPath Value="$(CompPath)"/> <CompilerPath Value="$(CompPath)"/>
</Other> </Other>
</CompilerOptions> </CompilerOptions>

View File

@ -27,7 +27,9 @@ uses
base_service_intf, server_service_soap, server_service_json, base_service_intf, server_service_soap, server_service_json,
base_binary_formatter, server_binary_formatter, base_binary_formatter, server_binary_formatter,
metadata_service, metadata_service_imp, metadata_service_binder, metadata_service, metadata_service_imp, metadata_service_binder,
server_listener , synapse_tcp_server, server_listener ,
//synapse_tcp_server,
indy_tcp_server,
user_service_intf, user_service_intf_binder, user_service_intf_imp , imp_helper, user_service_intf, user_service_intf_binder, user_service_intf_imp , imp_helper,
server_service_xmlrpc; server_service_xmlrpc;
@ -50,7 +52,8 @@ begin
WriteLn(Format('WST sample TCP Server listning on "%d"',[sSERVER_PORT])); WriteLn(Format('WST sample TCP Server listning on "%d"',[sSERVER_PORT]));
WriteLn('Hit <enter> to stop.'); WriteLn('Hit <enter> to stop.');
listener := TwstSynapseTcpListener.Create(); //listener := TwstSynapseTcpListener.Create();
listener := TwstIndyTcpListener.Create();
listener.Start(); listener.Start();
ReadLn; ReadLn;
end. end.

View File

@ -28,6 +28,14 @@
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/> <LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local> </local>
</RunParams> </RunParams>
<RequiredPackages Count="2">
<Item1>
<PackageName Value="wst_synapse"/>
</Item1>
<Item2>
<PackageName Value="wst_core"/>
</Item2>
</RequiredPackages>
<Units Count="2"> <Units Count="2">
<Unit0> <Unit0>
<Filename Value="user_client_console.pas"/> <Filename Value="user_client_console.pas"/>
@ -48,9 +56,14 @@
<Filename Value="user_client_console.exe"/> <Filename Value="user_client_console.exe"/>
</Target> </Target>
<SearchPaths> <SearchPaths>
<OtherUnitFiles Value="..\;..\..\;$(LazarusDir)\others_package\synapse\;$(LazarusDir)\others_package\ics\latest_distr\Delphi\Vc32\;..\..\fcl-units\fcl-json\src\"/> <OtherUnitFiles Value="..\;..\..\;..\..\fcl-units\fcl-json\src\"/>
<UnitOutputDirectory Value="obj"/> <UnitOutputDirectory Value="obj"/>
</SearchPaths> </SearchPaths>
<Parsing>
<SyntaxOptions>
<CStyleOperator Value="False"/>
</SyntaxOptions>
</Parsing>
<Linking> <Linking>
<Debugging> <Debugging>
<GenerateDebugInfo Value="True"/> <GenerateDebugInfo Value="True"/>

View File

@ -6,6 +6,8 @@ uses
Classes, SysUtils, TypInfo, {$IFDEF WINDOWS}ActiveX,{$ENDIF} Classes, SysUtils, TypInfo, {$IFDEF WINDOWS}ActiveX,{$ENDIF}
user_service_intf_proxy, user_service_intf_proxy,
same_process_protocol, synapse_tcp_protocol, synapse_http_protocol, library_protocol, same_process_protocol, synapse_tcp_protocol, synapse_http_protocol, library_protocol,
// same_process_protocol, indy_tcp_protocol, indy_http_protocol, library_protocol,
// same_process_protocol, ics_tcp_protocol, ics_http_protocol, library_protocol,
soap_formatter, binary_formatter, json_formatter, soap_formatter, binary_formatter, json_formatter,
user_service_intf, xmlrpc_formatter, service_intf; user_service_intf, xmlrpc_formatter, service_intf;
@ -89,8 +91,8 @@ begin
usr.Category:= Normal; usr.Category:= Normal;
usr.eMail := ReadItem('Enter user e-mail : ',False); usr.eMail := ReadItem('Enter user e-mail : ',False);
usr.Preferences := ReadItem('Enter user Preferences : ',False); usr.Preferences := ReadItem('Enter user Preferences : ',False);
buff := UpperCase(ReadItem('Do you want to add some notes : ',True)); buff := UpperCase(ReadItem('Do you want to add some notes : ',False));
if ( buff[1] = 'O' ) then begin if ( Length(buff) > 0 ) and ( buff[1] = 'Y' ) then begin
usr.Note.Header := ReadItem('Enter user Note.Header : ',False); usr.Note.Header := ReadItem('Enter user Note.Header : ',False);
usr.Note.Author := ReadItem('Enter user Note.Author : ',False); usr.Note.Author := ReadItem('Enter user Note.Author : ',False);
usr.Note.Date := ReadItem('Enter user Note.Date : ',False); usr.Note.Date := ReadItem('Enter user Note.Date : ',False);
@ -234,6 +236,10 @@ begin
{$IFEND} {$IFEND}
SYNAPSE_RegisterTCP_Transport(); SYNAPSE_RegisterTCP_Transport();
SYNAPSE_RegisterHTTP_Transport(); SYNAPSE_RegisterHTTP_Transport();
// INDY_RegisterTCP_Transport();
// INDY_RegisterHTTP_Transport();
// ICS_RegisterTCP_Transport();
// ICS_RegisterHTTP_Transport();
LIB_Register_Transport(); LIB_Register_Transport();
WriteLn('Sample Application using Web Services Toolkit'); WriteLn('Sample Application using Web Services Toolkit');
ReadFormatType(); ReadFormatType();

View File

@ -2,7 +2,7 @@
This unit has been produced by ws_helper. This unit has been produced by ws_helper.
Input unit name : "user_service_intf". Input unit name : "user_service_intf".
This unit name : "user_service_intf". This unit name : "user_service_intf".
Date : "29/12/2007 00:43:35". Date : "25/05/2009 01:53:09".
} }
unit user_service_intf; unit user_service_intf;
{$IFDEF FPC} {$IFDEF FPC}
@ -108,7 +108,7 @@ end;
function TUserArray.GetItem(AIndex: Integer): TUser; function TUserArray.GetItem(AIndex: Integer): TUser;
begin begin
Result := Inherited GetItem(AIndex) As TUser; Result := TUser(Inherited GetItem(AIndex));
end; end;
class function TUserArray.GetItemClass(): TBaseRemotableClass; class function TUserArray.GetItemClass(): TBaseRemotableClass;
@ -278,12 +278,16 @@ begin
end; end;
var
typeRegistryIntance : TTypeRegistry = nil;
initialization initialization
GetTypeRegistry().Register(sNAME_SPACE,TypeInfo(TUserCategory),'TUserCategory'); typeRegistryIntance := GetTypeRegistry();
GetTypeRegistry().Register(sNAME_SPACE,TypeInfo(TUser),'TUser');
GetTypeRegistry().Register(sNAME_SPACE,TypeInfo(TNote),'TNote'); typeRegistryIntance.Register(sNAME_SPACE,TypeInfo(TUserCategory),'TUserCategory');
GetTypeRegistry().Register(sNAME_SPACE,TypeInfo(TUserArray),'TUserArray'); typeRegistryIntance.Register(sNAME_SPACE,TypeInfo(TUser),'TUser');
GetTypeRegistry().ItemByTypeInfo[TypeInfo(TUserArray)].RegisterExternalPropertyName(sARRAY_ITEM,'item'); typeRegistryIntance.Register(sNAME_SPACE,TypeInfo(TNote),'TNote');
typeRegistryIntance.Register(sNAME_SPACE,TypeInfo(TUserArray),'TUserArray');
typeRegistryIntance.ItemByTypeInfo[TypeInfo(TUserArray)].RegisterExternalPropertyName(sARRAY_ITEM,'item');

View File

@ -2,7 +2,7 @@
This unit has been produced by ws_helper. This unit has been produced by ws_helper.
Input unit name : "user_service_intf". Input unit name : "user_service_intf".
This unit name : "user_service_intf_proxy". This unit name : "user_service_intf_proxy".
Date : "29/12/2007 00:43:35". Date : "25/05/2009 01:53:09".
} }
Unit user_service_intf_proxy; Unit user_service_intf_proxy;
@ -32,15 +32,20 @@ Type
):boolean; ):boolean;
End; End;
Function wst_CreateInstance_UserService(const AFormat : string = 'SOAP:'; const ATransport : string = 'HTTP:'):UserService; Function wst_CreateInstance_UserService(const AFormat : string = 'SOAP:'; const ATransport : string = 'HTTP:'; const AAddress : string = ''):UserService;
Implementation Implementation
uses wst_resources_imp, metadata_repository; uses wst_resources_imp, metadata_repository;
Function wst_CreateInstance_UserService(const AFormat : string; const ATransport : string):UserService; Function wst_CreateInstance_UserService(const AFormat : string; const ATransport : string; const AAddress : string):UserService;
Var
locAdr : string;
Begin Begin
Result := TUserService_Proxy.Create('UserService',AFormat+GetServiceDefaultFormatProperties(TypeInfo(UserService)),ATransport + 'address=' + GetServiceDefaultAddress(TypeInfo(UserService))); locAdr := AAddress;
if ( locAdr = '' ) then
locAdr := GetServiceDefaultAddress(TypeInfo(UserService));
Result := TUserService_Proxy.Create('UserService',AFormat+GetServiceDefaultFormatProperties(TypeInfo(UserService)),ATransport + 'address=' + locAdr);
End; End;
{ TUserService_Proxy implementation } { TUserService_Proxy implementation }
@ -53,19 +58,21 @@ end;
function TUserService_Proxy.GetList():TUserArray; function TUserService_Proxy.GetList():TUserArray;
Var Var
locSerializer : IFormatterClient; locSerializer : IFormatterClient;
strPrmName : string; locCallContext : ICallContext;
locStrPrmName : string;
Begin Begin
locCallContext := Self as ICallContext;
locSerializer := GetSerializer(); locSerializer := GetSerializer();
Try Try
locSerializer.BeginCall('GetList', GetTarget(),(Self as ICallContext)); locSerializer.BeginCall('GetList', GetTarget(),locCallContext);
locSerializer.EndCall(); locSerializer.EndCall();
MakeCall(); MakeCall();
locSerializer.BeginCallRead((Self as ICallContext)); locSerializer.BeginCallRead(locCallContext);
TObject(Result) := Nil; TObject(Result) := Nil;
strPrmName := 'result'; locStrPrmName := 'result';
locSerializer.Get(TypeInfo(TUserArray), strPrmName, Result); locSerializer.Get(TypeInfo(TUserArray), locStrPrmName, Result);
Finally Finally
locSerializer.Clear(); locSerializer.Clear();
@ -77,17 +84,19 @@ procedure TUserService_Proxy.Add(
); );
Var Var
locSerializer : IFormatterClient; locSerializer : IFormatterClient;
strPrmName : string; locCallContext : ICallContext;
locStrPrmName : string;
Begin Begin
locCallContext := Self as ICallContext;
locSerializer := GetSerializer(); locSerializer := GetSerializer();
Try Try
locSerializer.BeginCall('Add', GetTarget(),(Self as ICallContext)); locSerializer.BeginCall('Add', GetTarget(),locCallContext);
locSerializer.Put('AUser', TypeInfo(TUser), AUser); locSerializer.Put('AUser', TypeInfo(TUser), AUser);
locSerializer.EndCall(); locSerializer.EndCall();
MakeCall(); MakeCall();
locSerializer.BeginCallRead((Self as ICallContext)); locSerializer.BeginCallRead(locCallContext);
Finally Finally
locSerializer.Clear(); locSerializer.Clear();
@ -99,17 +108,19 @@ procedure TUserService_Proxy.Update(
); );
Var Var
locSerializer : IFormatterClient; locSerializer : IFormatterClient;
strPrmName : string; locCallContext : ICallContext;
locStrPrmName : string;
Begin Begin
locCallContext := Self as ICallContext;
locSerializer := GetSerializer(); locSerializer := GetSerializer();
Try Try
locSerializer.BeginCall('Update', GetTarget(),(Self as ICallContext)); locSerializer.BeginCall('Update', GetTarget(),locCallContext);
locSerializer.Put('AUser', TypeInfo(TUser), AUser); locSerializer.Put('AUser', TypeInfo(TUser), AUser);
locSerializer.EndCall(); locSerializer.EndCall();
MakeCall(); MakeCall();
locSerializer.BeginCallRead((Self as ICallContext)); locSerializer.BeginCallRead(locCallContext);
Finally Finally
locSerializer.Clear(); locSerializer.Clear();
@ -121,20 +132,22 @@ function TUserService_Proxy.Find(
):TUser; ):TUser;
Var Var
locSerializer : IFormatterClient; locSerializer : IFormatterClient;
strPrmName : string; locCallContext : ICallContext;
locStrPrmName : string;
Begin Begin
locCallContext := Self as ICallContext;
locSerializer := GetSerializer(); locSerializer := GetSerializer();
Try Try
locSerializer.BeginCall('Find', GetTarget(),(Self as ICallContext)); locSerializer.BeginCall('Find', GetTarget(),locCallContext);
locSerializer.Put('AName', TypeInfo(string), AName); locSerializer.Put('AName', TypeInfo(string), AName);
locSerializer.EndCall(); locSerializer.EndCall();
MakeCall(); MakeCall();
locSerializer.BeginCallRead((Self as ICallContext)); locSerializer.BeginCallRead(locCallContext);
TObject(Result) := Nil; TObject(Result) := Nil;
strPrmName := 'result'; locStrPrmName := 'result';
locSerializer.Get(TypeInfo(TUser), strPrmName, Result); locSerializer.Get(TypeInfo(TUser), locStrPrmName, Result);
Finally Finally
locSerializer.Clear(); locSerializer.Clear();
@ -146,19 +159,21 @@ function TUserService_Proxy.Delete(
):boolean; ):boolean;
Var Var
locSerializer : IFormatterClient; locSerializer : IFormatterClient;
strPrmName : string; locCallContext : ICallContext;
locStrPrmName : string;
Begin Begin
locCallContext := Self as ICallContext;
locSerializer := GetSerializer(); locSerializer := GetSerializer();
Try Try
locSerializer.BeginCall('Delete', GetTarget(),(Self as ICallContext)); locSerializer.BeginCall('Delete', GetTarget(),locCallContext);
locSerializer.Put('AName', TypeInfo(string), AName); locSerializer.Put('AName', TypeInfo(string), AName);
locSerializer.EndCall(); locSerializer.EndCall();
MakeCall(); MakeCall();
locSerializer.BeginCallRead((Self as ICallContext)); locSerializer.BeginCallRead(locCallContext);
strPrmName := 'result'; locStrPrmName := 'result';
locSerializer.Get(TypeInfo(boolean), strPrmName, Result); locSerializer.Get(TypeInfo(boolean), locStrPrmName, Result);
Finally Finally
locSerializer.Clear(); locSerializer.Clear();

View File

@ -12,7 +12,7 @@
} }
{$INCLUDE wst_global.inc} {$INCLUDE wst_global.inc}
unit synapse_tcp_protocol; unit synapse_tcp_protocol;
interface interface
uses uses
@ -124,7 +124,7 @@ begin
wrtr.WriteAnsiStr(Self.Format); wrtr.WriteAnsiStr(Self.Format);
SetLength(binBuff,ARequest.Size); SetLength(binBuff,ARequest.Size);
ARequest.Position := 0; ARequest.Position := 0;
ARequest.Read(binBuff[1],Length(binBuff)); ARequest.Read(binBuff[0],Length(binBuff));
wrtr.WriteBinary(binBuff); wrtr.WriteBinary(binBuff);
buffStream.Position := 0; buffStream.Position := 0;
wrtr.WriteInt32S(buffStream.Size-4); wrtr.WriteInt32S(buffStream.Size-4);
@ -146,9 +146,9 @@ begin
i := bufferLen; i := bufferLen;
SetLength(binBuff,i); SetLength(binBuff,i);
repeat repeat
j := FConnection.RecvBufferEx(@(binBuff[1]),i,DefaultTimeOut); j := FConnection.RecvBufferEx(@(binBuff[0]),i,DefaultTimeOut);
FConnection.ExceptCheck(); FConnection.ExceptCheck();
AResponse.Write(binBuff[1],j); AResponse.Write(binBuff[0],j);
Inc(c,j); Inc(c,j);
i := Min(1024,(bufferLen-c)); i := Min(1024,(bufferLen-c));
until ( i =0 ) or ( j <= 0 ); until ( i =0 ) or ( j <= 0 );

View File

@ -121,9 +121,9 @@ begin
i := bufferLen; i := bufferLen;
SetLength(binBuff,i); SetLength(binBuff,i);
repeat repeat
j := FSocketObject.RecvBufferEx(@(binBuff[1]),i,DefaultTimeOut); j := FSocketObject.RecvBufferEx(@(binBuff[0]),i,DefaultTimeOut);
FSocketObject.ExceptCheck(); FSocketObject.ExceptCheck();
FInputStream.Write(binBuff[1],j); FInputStream.Write(binBuff[0],j);
Inc(c,j); Inc(c,j);
if ( ( bufferLen - c ) > 1024 ) then if ( ( bufferLen - c ) > 1024 ) then
i := 1024 i := 1024
@ -200,7 +200,7 @@ begin
buff := rdr.ReadBinary(); buff := rdr.ReadBinary();
rdr := nil; rdr := nil;
FInputStream.Size := 0; FInputStream.Size := 0;
FInputStream.Write(buff[1],Length(buff)); FInputStream.Write(buff[0],Length(buff));
SetLength(buff,0); SetLength(buff,0);
FInputStream.Position := 0; FInputStream.Position := 0;
rqst := TRequestBuffer.Create(trgt,ctntyp,FInputStream,FOutputStream,frmt); rqst := TRequestBuffer.Create(trgt,ctntyp,FInputStream,FOutputStream,frmt);
@ -210,7 +210,7 @@ begin
i := FOutputStream.Size; i := FOutputStream.Size;
SetLength(buff,i); SetLength(buff,i);
FOutputStream.Position := 0; FOutputStream.Position := 0;
FOutputStream.Read(buff[1],i); FOutputStream.Read(buff[0],i);
FOutputStream.Size := 0; FOutputStream.Size := 0;
wrtr := CreateBinaryWriter(FOutputStream); wrtr := CreateBinaryWriter(FOutputStream);
wrtr.WriteBinary(buff); wrtr.WriteBinary(buff);