diff --git a/wst/trunk/binary_streamer.pas b/wst/trunk/binary_streamer.pas index c0f02b0d7..e4b01936a 100644 --- a/wst/trunk/binary_streamer.pas +++ b/wst/trunk/binary_streamer.pas @@ -449,7 +449,7 @@ begin i := Length(AData); WriteInt32S(i); if ( i > 0 ) then - FStream.Write(AData[1],i); + FStream.Write(AData[0],i); end; {$IFDEF WST_UNICODESTRING} @@ -637,7 +637,7 @@ begin i := ReadInt32S(); SetLength(Result,i); if ( i > 0 ) then - FStream.ReadBuffer(Result[1],i); + FStream.ReadBuffer(Result[0],i); end; {$IFDEF WST_UNICODESTRING} diff --git a/wst/trunk/indy_tcp_protocol.pas b/wst/trunk/indy_tcp_protocol.pas index 70127a65d..efaa4a050 100644 --- a/wst/trunk/indy_tcp_protocol.pas +++ b/wst/trunk/indy_tcp_protocol.pas @@ -125,7 +125,7 @@ begin wrtr.WriteAnsiStr(Self.Format); SetLength(binBuff,ARequest.Size); ARequest.Position := 0; - ARequest.Read(binBuff[1],Length(binBuff)); + ARequest.Read(binBuff[0],Length(binBuff)); wrtr.WriteBinary(binBuff); buffStream.Position := 0; wrtr.WriteInt32S(buffStream.Size-4); diff --git a/wst/trunk/indy_tcp_server.pas b/wst/trunk/indy_tcp_server.pas index 6bde457a6..b53e55508 100644 --- a/wst/trunk/indy_tcp_server.pas +++ b/wst/trunk/indy_tcp_server.pas @@ -163,13 +163,9 @@ begin frmt := rdr.ReadAnsiStr(); buff := rdr.ReadBinary(); -{$IFDEF WST_DBG} - WriteLn(buff); -{$ENDIF} - rdr := nil; locInStream.Size := 0; - locInStream.Write(buff[1],Length(buff)); + locInStream.Write(buff[0],Length(buff)); SetLength(buff,0); locInStream.Position := 0; rqst := TRequestBuffer.Create(trgt,ctntyp,locInStream,locOutStream,frmt); @@ -179,7 +175,7 @@ begin i := locOutStream.Size; SetLength(buff,i); locOutStream.Position := 0; - locOutStream.Read(buff[1],i); + locOutStream.Read(buff[0],i); locOutStream.Size := 0; wrtr := CreateBinaryWriter(locOutStream); wrtr.WriteBinary(buff); diff --git a/wst/trunk/library_protocol.pas b/wst/trunk/library_protocol.pas index e2d815d3a..7b58b7608 100644 --- a/wst/trunk/library_protocol.pas +++ b/wst/trunk/library_protocol.pas @@ -105,9 +105,10 @@ procedure TLIBTransport.SendAndReceive(ARequest, AResponse: TStream); Var wrtr : IDataStore; buffStream : TMemoryStream; - strBuff : TBinaryString; + buff : TByteDynArray; intfBuffer : IwstStream; bl : LongInt; + errorStrBuffer : ansistring; {$IFDEF WST_DBG} s : TBinaryString; i : Int64; @@ -121,23 +122,19 @@ begin wrtr.WriteAnsiStr(Target); wrtr.WriteAnsiStr(ContentType); wrtr.WriteAnsiStr(Self.Format); - SetLength(strBuff,ARequest.Size); + SetLength(buff,ARequest.Size); ARequest.Position := 0; - ARequest.Read(strBuff[1],Length(strBuff)); -{$IFDEF WST_DBG} - if IsConsole then - WriteLn(strBuff); -{$ENDIF WST_DBG} - wrtr.WriteAnsiStr(strBuff); + ARequest.Read(buff[0],Length(buff)); + wrtr.WriteBinary(buff); buffStream.Position := 0; wrtr.WriteInt32S(buffStream.Size-4); buffStream.Position := 0; intfBuffer := TwstStream.Create(buffStream); bl := MAX_ERR_LEN; - strBuff := StringOfChar(#0,bl); - if ( FHandler(intfBuffer,Pointer(strBuff),bl) <> RET_OK ) then - raise Exception.Create(strBuff); + errorStrBuffer := StringOfChar(#0,bl); + if ( FHandler(intfBuffer,Pointer(errorStrBuffer),bl) <> RET_OK ) then + raise Exception.Create(errorStrBuffer); buffStream.Position := 0; AResponse.Size := 0; diff --git a/wst/trunk/library_server_intf.pas b/wst/trunk/library_server_intf.pas index 6fa12ff41..157a3b234 100644 --- a/wst/trunk/library_server_intf.pas +++ b/wst/trunk/library_server_intf.pas @@ -51,7 +51,8 @@ function wstHandleRequest( end; Var - buff, trgt,ctntyp, frmt : TBinaryString; + trgt,ctntyp, frmt : TBinaryString; + binBuff : TByteDynArray; rqst : IRequestBuffer; rdr : IDataStoreReader; inStream, bufStream : TMemoryStream; @@ -82,12 +83,12 @@ begin trgt := rdr.ReadAnsiStr(); ctntyp := rdr.ReadAnsiStr(); frmt := rdr.ReadAnsiStr(); - buff := rdr.ReadAnsiStr(); + binBuff := rdr.ReadBinary(); rdr := nil; bufStream.Size := 0; bufStream.Position := 0; - inStream.Write(buff[1],Length(buff)); - SetLength(buff,0); + inStream.Write(binBuff[0],Length(binBuff)); + SetLength(binBuff,0); inStream.Position := 0; rqst := TRequestBuffer.Create(trgt,ctntyp,inStream,bufStream,frmt); HandleServiceRequest(rqst); diff --git a/wst/trunk/metadata_repository.pas b/wst/trunk/metadata_repository.pas index 9dcefbd2d..3da860215 100644 --- a/wst/trunk/metadata_repository.pas +++ b/wst/trunk/metadata_repository.pas @@ -45,7 +45,7 @@ type Modifier : TOperationParamFlag; end; - PServiceOperation = ^TServiceOperation; + PServiceOperation = ^TServiceOperation; TServiceOperation = record Name : ShortString; ParamsCount : Byte; @@ -279,6 +279,8 @@ begin end; Freemem(AService^.Operations, k * SizeOf(TServiceOperation) ); AService^.Operations := nil; + end; + if ( AService^.Properties <> nil ) then begin ClearProperties(AService^.Properties); AService^.Properties := nil; end; diff --git a/wst/trunk/samples/library_server/lib_server.lpi b/wst/trunk/samples/library_server/lib_server.lpi index a270519df..379310b36 100644 --- a/wst/trunk/samples/library_server/lib_server.lpi +++ b/wst/trunk/samples/library_server/lib_server.lpi @@ -2,11 +2,13 @@ - + + + + - @@ -34,7 +36,7 @@ - + @@ -44,9 +46,6 @@ - - - diff --git a/wst/trunk/samples/tcp_server/tcp_server.lpi b/wst/trunk/samples/tcp_server/tcp_server.lpi index 0414d56de..1c50c8704 100644 --- a/wst/trunk/samples/tcp_server/tcp_server.lpi +++ b/wst/trunk/samples/tcp_server/tcp_server.lpi @@ -2,16 +2,16 @@ - + + - @@ -28,6 +28,11 @@ + + + + + @@ -52,7 +57,7 @@ - + @@ -69,10 +74,8 @@ - - - + diff --git a/wst/trunk/samples/tcp_server/tcp_server.pas b/wst/trunk/samples/tcp_server/tcp_server.pas index a85951b05..144ffb87d 100644 --- a/wst/trunk/samples/tcp_server/tcp_server.pas +++ b/wst/trunk/samples/tcp_server/tcp_server.pas @@ -27,7 +27,9 @@ uses base_service_intf, server_service_soap, server_service_json, base_binary_formatter, server_binary_formatter, 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, server_service_xmlrpc; @@ -50,7 +52,8 @@ begin WriteLn(Format('WST sample TCP Server listning on "%d"',[sSERVER_PORT])); WriteLn('Hit to stop.'); - listener := TwstSynapseTcpListener.Create(); + //listener := TwstSynapseTcpListener.Create(); + listener := TwstIndyTcpListener.Create(); listener.Start(); ReadLn; end. diff --git a/wst/trunk/samples/user_client_console/user_client_console.lpi b/wst/trunk/samples/user_client_console/user_client_console.lpi index e0233b079..e1bc86f20 100644 --- a/wst/trunk/samples/user_client_console/user_client_console.lpi +++ b/wst/trunk/samples/user_client_console/user_client_console.lpi @@ -28,6 +28,14 @@ + + + + + + + + @@ -48,9 +56,14 @@ - + + + + + + diff --git a/wst/trunk/samples/user_client_console/user_client_console.pas b/wst/trunk/samples/user_client_console/user_client_console.pas index 111184e91..b0d43a039 100644 --- a/wst/trunk/samples/user_client_console/user_client_console.pas +++ b/wst/trunk/samples/user_client_console/user_client_console.pas @@ -6,6 +6,8 @@ uses Classes, SysUtils, TypInfo, {$IFDEF WINDOWS}ActiveX,{$ENDIF} user_service_intf_proxy, 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, user_service_intf, xmlrpc_formatter, service_intf; @@ -89,8 +91,8 @@ begin usr.Category:= Normal; usr.eMail := ReadItem('Enter user e-mail : ',False); usr.Preferences := ReadItem('Enter user Preferences : ',False); - buff := UpperCase(ReadItem('Do you want to add some notes : ',True)); - if ( buff[1] = 'O' ) then begin + buff := UpperCase(ReadItem('Do you want to add some notes : ',False)); + if ( Length(buff) > 0 ) and ( buff[1] = 'Y' ) then begin usr.Note.Header := ReadItem('Enter user Note.Header : ',False); usr.Note.Author := ReadItem('Enter user Note.Author : ',False); usr.Note.Date := ReadItem('Enter user Note.Date : ',False); @@ -234,6 +236,10 @@ begin {$IFEND} SYNAPSE_RegisterTCP_Transport(); SYNAPSE_RegisterHTTP_Transport(); +// INDY_RegisterTCP_Transport(); +// INDY_RegisterHTTP_Transport(); +// ICS_RegisterTCP_Transport(); +// ICS_RegisterHTTP_Transport(); LIB_Register_Transport(); WriteLn('Sample Application using Web Services Toolkit'); ReadFormatType(); diff --git a/wst/trunk/samples/user_service_intf.pas b/wst/trunk/samples/user_service_intf.pas index 45e019084..1fc95b4f1 100644 --- a/wst/trunk/samples/user_service_intf.pas +++ b/wst/trunk/samples/user_service_intf.pas @@ -2,7 +2,7 @@ This unit has been produced by ws_helper. Input 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; {$IFDEF FPC} @@ -108,7 +108,7 @@ end; function TUserArray.GetItem(AIndex: Integer): TUser; begin - Result := Inherited GetItem(AIndex) As TUser; + Result := TUser(Inherited GetItem(AIndex)); end; class function TUserArray.GetItemClass(): TBaseRemotableClass; @@ -278,12 +278,16 @@ begin end; +var + typeRegistryIntance : TTypeRegistry = nil; initialization - GetTypeRegistry().Register(sNAME_SPACE,TypeInfo(TUserCategory),'TUserCategory'); - GetTypeRegistry().Register(sNAME_SPACE,TypeInfo(TUser),'TUser'); - GetTypeRegistry().Register(sNAME_SPACE,TypeInfo(TNote),'TNote'); - GetTypeRegistry().Register(sNAME_SPACE,TypeInfo(TUserArray),'TUserArray'); - GetTypeRegistry().ItemByTypeInfo[TypeInfo(TUserArray)].RegisterExternalPropertyName(sARRAY_ITEM,'item'); + typeRegistryIntance := GetTypeRegistry(); + + typeRegistryIntance.Register(sNAME_SPACE,TypeInfo(TUserCategory),'TUserCategory'); + typeRegistryIntance.Register(sNAME_SPACE,TypeInfo(TUser),'TUser'); + typeRegistryIntance.Register(sNAME_SPACE,TypeInfo(TNote),'TNote'); + typeRegistryIntance.Register(sNAME_SPACE,TypeInfo(TUserArray),'TUserArray'); + typeRegistryIntance.ItemByTypeInfo[TypeInfo(TUserArray)].RegisterExternalPropertyName(sARRAY_ITEM,'item'); diff --git a/wst/trunk/samples/user_service_intf_proxy.pas b/wst/trunk/samples/user_service_intf_proxy.pas index f95c91400..00ecee4d4 100644 --- a/wst/trunk/samples/user_service_intf_proxy.pas +++ b/wst/trunk/samples/user_service_intf_proxy.pas @@ -2,7 +2,7 @@ This unit has been produced by ws_helper. Input unit name : "user_service_intf". 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; @@ -32,15 +32,20 @@ Type ):boolean; 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 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 - 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; { TUserService_Proxy implementation } @@ -53,19 +58,21 @@ end; function TUserService_Proxy.GetList():TUserArray; Var locSerializer : IFormatterClient; - strPrmName : string; + locCallContext : ICallContext; + locStrPrmName : string; Begin + locCallContext := Self as ICallContext; locSerializer := GetSerializer(); Try - locSerializer.BeginCall('GetList', GetTarget(),(Self as ICallContext)); + locSerializer.BeginCall('GetList', GetTarget(),locCallContext); locSerializer.EndCall(); MakeCall(); - locSerializer.BeginCallRead((Self as ICallContext)); + locSerializer.BeginCallRead(locCallContext); TObject(Result) := Nil; - strPrmName := 'result'; - locSerializer.Get(TypeInfo(TUserArray), strPrmName, Result); + locStrPrmName := 'result'; + locSerializer.Get(TypeInfo(TUserArray), locStrPrmName, Result); Finally locSerializer.Clear(); @@ -77,17 +84,19 @@ procedure TUserService_Proxy.Add( ); Var locSerializer : IFormatterClient; - strPrmName : string; + locCallContext : ICallContext; + locStrPrmName : string; Begin + locCallContext := Self as ICallContext; locSerializer := GetSerializer(); Try - locSerializer.BeginCall('Add', GetTarget(),(Self as ICallContext)); + locSerializer.BeginCall('Add', GetTarget(),locCallContext); locSerializer.Put('AUser', TypeInfo(TUser), AUser); locSerializer.EndCall(); MakeCall(); - locSerializer.BeginCallRead((Self as ICallContext)); + locSerializer.BeginCallRead(locCallContext); Finally locSerializer.Clear(); @@ -99,17 +108,19 @@ procedure TUserService_Proxy.Update( ); Var locSerializer : IFormatterClient; - strPrmName : string; + locCallContext : ICallContext; + locStrPrmName : string; Begin + locCallContext := Self as ICallContext; locSerializer := GetSerializer(); Try - locSerializer.BeginCall('Update', GetTarget(),(Self as ICallContext)); + locSerializer.BeginCall('Update', GetTarget(),locCallContext); locSerializer.Put('AUser', TypeInfo(TUser), AUser); locSerializer.EndCall(); MakeCall(); - locSerializer.BeginCallRead((Self as ICallContext)); + locSerializer.BeginCallRead(locCallContext); Finally locSerializer.Clear(); @@ -121,20 +132,22 @@ function TUserService_Proxy.Find( ):TUser; Var locSerializer : IFormatterClient; - strPrmName : string; + locCallContext : ICallContext; + locStrPrmName : string; Begin + locCallContext := Self as ICallContext; locSerializer := GetSerializer(); Try - locSerializer.BeginCall('Find', GetTarget(),(Self as ICallContext)); + locSerializer.BeginCall('Find', GetTarget(),locCallContext); locSerializer.Put('AName', TypeInfo(string), AName); locSerializer.EndCall(); MakeCall(); - locSerializer.BeginCallRead((Self as ICallContext)); + locSerializer.BeginCallRead(locCallContext); TObject(Result) := Nil; - strPrmName := 'result'; - locSerializer.Get(TypeInfo(TUser), strPrmName, Result); + locStrPrmName := 'result'; + locSerializer.Get(TypeInfo(TUser), locStrPrmName, Result); Finally locSerializer.Clear(); @@ -146,19 +159,21 @@ function TUserService_Proxy.Delete( ):boolean; Var locSerializer : IFormatterClient; - strPrmName : string; + locCallContext : ICallContext; + locStrPrmName : string; Begin + locCallContext := Self as ICallContext; locSerializer := GetSerializer(); Try - locSerializer.BeginCall('Delete', GetTarget(),(Self as ICallContext)); + locSerializer.BeginCall('Delete', GetTarget(),locCallContext); locSerializer.Put('AName', TypeInfo(string), AName); locSerializer.EndCall(); MakeCall(); - locSerializer.BeginCallRead((Self as ICallContext)); - strPrmName := 'result'; - locSerializer.Get(TypeInfo(boolean), strPrmName, Result); + locSerializer.BeginCallRead(locCallContext); + locStrPrmName := 'result'; + locSerializer.Get(TypeInfo(boolean), locStrPrmName, Result); Finally locSerializer.Clear(); diff --git a/wst/trunk/synapse_tcp_protocol.pas b/wst/trunk/synapse_tcp_protocol.pas index 05233a4cf..152f9fd94 100644 --- a/wst/trunk/synapse_tcp_protocol.pas +++ b/wst/trunk/synapse_tcp_protocol.pas @@ -12,7 +12,7 @@ } {$INCLUDE wst_global.inc} unit synapse_tcp_protocol; - + interface uses @@ -124,7 +124,7 @@ begin wrtr.WriteAnsiStr(Self.Format); SetLength(binBuff,ARequest.Size); ARequest.Position := 0; - ARequest.Read(binBuff[1],Length(binBuff)); + ARequest.Read(binBuff[0],Length(binBuff)); wrtr.WriteBinary(binBuff); buffStream.Position := 0; wrtr.WriteInt32S(buffStream.Size-4); @@ -146,9 +146,9 @@ begin i := bufferLen; SetLength(binBuff,i); repeat - j := FConnection.RecvBufferEx(@(binBuff[1]),i,DefaultTimeOut); + j := FConnection.RecvBufferEx(@(binBuff[0]),i,DefaultTimeOut); FConnection.ExceptCheck(); - AResponse.Write(binBuff[1],j); + AResponse.Write(binBuff[0],j); Inc(c,j); i := Min(1024,(bufferLen-c)); until ( i =0 ) or ( j <= 0 ); diff --git a/wst/trunk/synapse_tcp_server.pas b/wst/trunk/synapse_tcp_server.pas index 179197235..497453e98 100644 --- a/wst/trunk/synapse_tcp_server.pas +++ b/wst/trunk/synapse_tcp_server.pas @@ -121,9 +121,9 @@ begin i := bufferLen; SetLength(binBuff,i); repeat - j := FSocketObject.RecvBufferEx(@(binBuff[1]),i,DefaultTimeOut); + j := FSocketObject.RecvBufferEx(@(binBuff[0]),i,DefaultTimeOut); FSocketObject.ExceptCheck(); - FInputStream.Write(binBuff[1],j); + FInputStream.Write(binBuff[0],j); Inc(c,j); if ( ( bufferLen - c ) > 1024 ) then i := 1024 @@ -200,7 +200,7 @@ begin buff := rdr.ReadBinary(); rdr := nil; FInputStream.Size := 0; - FInputStream.Write(buff[1],Length(buff)); + FInputStream.Write(buff[0],Length(buff)); SetLength(buff,0); FInputStream.Position := 0; rqst := TRequestBuffer.Create(trgt,ctntyp,FInputStream,FOutputStream,frmt); @@ -210,7 +210,7 @@ begin i := FOutputStream.Size; SetLength(buff,i); FOutputStream.Position := 0; - FOutputStream.Read(buff[1],i); + FOutputStream.Read(buff[0],i); FOutputStream.Size := 0; wrtr := CreateBinaryWriter(FOutputStream); wrtr.WriteBinary(buff);