diff --git a/packages/fcl-web/fpmake.pp b/packages/fcl-web/fpmake.pp index c63ab58ce0..94cba5edcf 100644 --- a/packages/fcl-web/fpmake.pp +++ b/packages/fcl-web/fpmake.pp @@ -302,8 +302,9 @@ begin AddUnit('httpdefs'); AddUnit('fpextjs'); end; - T:=P.Targets.AddUnit('fpjsonrpc.pp'); + T:=P.Targets.AddUnit('fprpcstrings.pp'); T.ResourceStrings:=true; + T:=P.Targets.AddUnit('fpjsonrpc.pp'); T:=P.Targets.AddUnit('webjsonrpc.pp'); With T.Dependencies do begin @@ -314,9 +315,7 @@ begin begin AddUnit('fpjsonrpc'); end; -// T.ResourceStrings:=true; T:=P.Targets.AddUnit('fprpcclient.pp'); - T.ResourceStrings:=true; T:=P.Targets.AddUnit('fprpccodegen.pp'); T:=P.Targets.AddUnit('fpdispextdirect.pp'); With T.Dependencies do @@ -324,7 +323,6 @@ begin AddUnit('fpjsonrpc'); end; T:=P.Targets.AddUnit('fpextdirect.pp'); - T.ResourceStrings:=true; With T.Dependencies do begin AddUnit('fpdispextdirect'); diff --git a/packages/fcl-web/src/jsonrpc/fpextdirect.pp b/packages/fcl-web/src/jsonrpc/fpextdirect.pp index f1b96d73c1..805af36879 100644 --- a/packages/fcl-web/src/jsonrpc/fpextdirect.pp +++ b/packages/fcl-web/src/jsonrpc/fpextdirect.pp @@ -120,12 +120,10 @@ Type implementation -{$ifdef extdebug} -uses dbugintf; -{$endif} -Resourcestring - SErrInvalidPath = 'Invalid path'; +uses {$ifdef extdebug}dbugintf,{$endif} fprpcstrings; + + { TCustomExtDirectDispatcher } diff --git a/packages/fcl-web/src/jsonrpc/fpjsonrpc.pp b/packages/fcl-web/src/jsonrpc/fpjsonrpc.pp index 74c608c4f7..527140c98d 100644 --- a/packages/fcl-web/src/jsonrpc/fpjsonrpc.pp +++ b/packages/fcl-web/src/jsonrpc/fpjsonrpc.pp @@ -446,47 +446,10 @@ Const EJSONRPCInvalidParams = -32602; EJSONRPCInternalError = -32603; - -resourcestring - SErrDuplicateParam = 'Duplicate JSON-RPC Parameter name'; - SErrUnknownParamDef = 'Unknown parameter definition: "%s"'; - SErrParams = 'Error checking JSON-RPC parameters: "%s"'; - SErrParamsMustBeArrayorObject = 'Parameters must be passed in an object or an array.'; - SErrParamsMustBeObject = 'Parameters must be passed in an object.'; - SErrParamsMustBeArray = 'Parameters must be passed in an array.'; - SErrParamsRequiredParamNotFound = 'Required parameter "%s" not found.'; - SErrParamsDataTypeMismatch = 'Expected parameter "%s" having type "%s", got "%s".'; - SErrParamsNotAllowd = 'Parameter "%s" is not allowed.'; - SErrParamsOnlyObjectsInArray = 'Array elements must be objects, got %s at position %d.'; - SErrRequestMustBeObject = 'JSON-RPC Request must be an object.'; - SErrNoIDProperty = 'No "id" property found in request.'; - SErrInvalidIDProperty = 'Type of "id" property is not correct.'; - SErrNoJSONRPCProperty = 'No "jsonrpc" property in request.'; - SErrInvalidJSONRPCProperty = 'Type or value of "jsonrpc" property is not correct.'; - SErrNoMethodName = 'Cannot determine method: No "%s" property found in request.'; - SErrNoClassName = 'Cannot determine class: No "%s" property found in request.'; - SErrNoParams = 'Cannot determine parameters: No "%s" property found in request.'; - SErrInvalidMethodType = 'Type of "%s" property in request is not correct.'; - SErrInvalidClassNameType = 'Type of "%s" property in request is not correct.'; - SErrJSON2NotAllowed = 'JSON RPC 2 calls are not allowed.'; - SErrJSON1NotAllowed = 'JSON RPC 1 calls are not allowed.'; - SErrNoResponse = 'No response received from non-notification method "%s".'; - SErrResponseFromNotification = 'A response was received from a notification method "%s".'; - SErrInvalidMethodName = 'No method "%s" was found.'; - SErrInvalidClassMethodName = 'No class "%s" with method "%s" was found.'; - SErrDuplicateJSONRPCClassHandlerName = 'Duplicate JSON-RPC handler for class "%s" with method "%s".'; - SErrDuplicateJSONRPCHandlerName = 'Duplicate JSON-RPC handler for method "%s".'; - SErrUnknownJSONRPCClassMethodHandler = 'Unknown JSON-RPC handler for class "%s", method "%s".'; - SErrUnknownJSONRPCMethodHandler = 'Unknown JSON-RPC handler for method "%s".'; - SErrDuplicateRPCCLassMethodHandler = 'Duplicate JSON-RPC handler for class "%s", method "%s".'; - SErrDuplicateRPCMethodHandler = 'Duplicate JSON-RPC handler for method "%s".'; - SErrNoDispatcher = 'No method dispatcher available to handle request.'; - - implementation -uses {$IFDEF WMDEBUG}dbugintf, {$ENDIF} fprpccodegen; +uses {$IFDEF WMDEBUG}dbugintf, {$ENDIF} fprpccodegen, fprpcstrings; function CreateJSONErrorObject(const AMessage: String; const ACode: Integer ): TJSONObject; diff --git a/packages/fcl-web/src/jsonrpc/fprpcclient.pp b/packages/fcl-web/src/jsonrpc/fprpcclient.pp index 6cdd4a36f5..909e6c3677 100644 --- a/packages/fcl-web/src/jsonrpc/fprpcclient.pp +++ b/packages/fcl-web/src/jsonrpc/fprpcclient.pp @@ -123,14 +123,10 @@ Type Function RPCServiceRegistry : TFPRPCServiceRegistry; -Resourcestring - SErrUnknownServiceName = 'Unknown service name : "%s"'; - SErrUnknownServiceGUID = 'Unknown service GUID : "%s"'; - SErrSupportedServiceName = 'Interface does not support service: "%s"'; - SErrExpectedReturnButNoServerReturn = 'Method "%s" expects return values, but no result was returned'; - implementation +uses fprpcstrings; + function IsGUIDEqual(const guid1, guid2: tguid): boolean; begin IsGUIDEqual:= @@ -480,10 +476,10 @@ begin Req:=aClient.CreateRequest; try S:=aRequest.AsJSON; - Writeln('Request : ',S); + // Writeln('Request : ',S); Req.Content.WriteBuffer(S[1],Length(S)); Resp:=aClient.ExecuteRequest('POST',FBaseURL,Req); - Writeln('Response : ',Resp.GetContentAsString); + // Writeln('Response : ',Resp.GetContentAsString); // For notification methods, there is no return ! if (resp.Content.Size>0) then begin @@ -494,7 +490,7 @@ begin else begin Res.Free; - Raise ERPCClient.Create('Invalid server response'); + Raise ERPCClient.Create(SErrInvalidServerResponse); end; end; finally diff --git a/packages/fcl-web/src/jsonrpc/fprpcrtti.pp b/packages/fcl-web/src/jsonrpc/fprpcrtti.pp index 56336a3609..47740979d4 100644 --- a/packages/fcl-web/src/jsonrpc/fprpcrtti.pp +++ b/packages/fcl-web/src/jsonrpc/fprpcrtti.pp @@ -86,7 +86,7 @@ function RTTIJSONRPCRegistry : TRTTIJSONRPCRegistry; implementation -uses fpjsonvalue; +uses fprpcstrings, fpjsonvalue; function RTTIJSONRPCRegistry : TRTTIJSONRPCRegistry; @@ -194,7 +194,7 @@ begin TRTTIJSONRPCRegistry.Instance.Get(FRPCClassName,FIntfType,FCreator); FMethod:=FIntfType.GetMethod(aMethodName); if FMethod=Nil then - Raise EJSONRPC.CreateFmt('unknown method name for class %s: %s',[aClassName,aMethodName]); + raise EJSONRPC.CreateFmt(SErrUnknownMethodForClass, [aClassName, aMethodName]); end; class function TRTTIJSONRPCHandler.ValueToJSON(const aValue: TValue; aType: TRttiType): TJSONData; @@ -253,7 +253,7 @@ begin if (Intf.QueryInterface(IRPCCallContext,CC)=S_OK) then CC.RPCCallContext:=aContext; if Intf.QueryInterface(FIntfType.GUID,APIIntf)<>S_OK then - Raise EJSONRPC.CreateFmt('Creator does not support interface %s',[FIntfType.Name]); + raise EJSONRPC.CreateFmt(SErrCreatorDoesNotSupportInterface, [FIntfType.Name]); TValue.Make(@APIIntf, PTypeInfo(FIntfType.Handle), instance); res := method.Invoke(instance, args); diff --git a/packages/fcl-web/src/jsonrpc/fprpcstrings.pp b/packages/fcl-web/src/jsonrpc/fprpcstrings.pp new file mode 100644 index 0000000000..e0c1c62f8c --- /dev/null +++ b/packages/fcl-web/src/jsonrpc/fprpcstrings.pp @@ -0,0 +1,53 @@ +unit fprpcstrings; + +{$mode ObjFPC}{$H+} + +interface + +Resourcestring + SErrInvalidPath = 'Invalid path'; + SErrUnknownServiceName = 'Unknown service name : "%s"'; + SErrUnknownServiceGUID = 'Unknown service GUID : "%s"'; + SErrSupportedServiceName = 'Interface does not support service: "%s"'; + SErrExpectedReturnButNoServerReturn = 'Method "%s" expects return values, but no result was returned'; + SErrInvalidServerResponse = 'Invalid server response'; + SErrDuplicateParam = 'Duplicate JSON-RPC Parameter name'; + SErrUnknownParamDef = 'Unknown parameter definition: "%s"'; + SErrParams = 'Error checking JSON-RPC parameters: "%s"'; + SErrParamsMustBeArrayorObject = 'Parameters must be passed in an object or an array.'; + SErrParamsMustBeObject = 'Parameters must be passed in an object.'; + SErrParamsMustBeArray = 'Parameters must be passed in an array.'; + SErrParamsRequiredParamNotFound = 'Required parameter "%s" not found.'; + SErrParamsDataTypeMismatch = 'Expected parameter "%s" having type "%s", got "%s".'; + SErrParamsNotAllowd = 'Parameter "%s" is not allowed.'; + SErrParamsOnlyObjectsInArray = 'Array elements must be objects, got %s at position %d.'; + SErrRequestMustBeObject = 'JSON-RPC Request must be an object.'; + SErrNoIDProperty = 'No "id" property found in request.'; + SErrInvalidIDProperty = 'Type of "id" property is not correct.'; + SErrNoJSONRPCProperty = 'No "jsonrpc" property in request.'; + SErrInvalidJSONRPCProperty = 'Type or value of "jsonrpc" property is not correct.'; + SErrNoMethodName = 'Cannot determine method: No "%s" property found in request.'; + SErrNoClassName = 'Cannot determine class: No "%s" property found in request.'; + SErrNoParams = 'Cannot determine parameters: No "%s" property found in request.'; + SErrInvalidMethodType = 'Type of "%s" property in request is not correct.'; + SErrInvalidClassNameType = 'Type of "%s" property in request is not correct.'; + SErrJSON2NotAllowed = 'JSON RPC 2 calls are not allowed.'; + SErrJSON1NotAllowed = 'JSON RPC 1 calls are not allowed.'; + SErrNoResponse = 'No response received from non-notification method "%s".'; + SErrResponseFromNotification = 'A response was received from a notification method "%s".'; + SErrInvalidMethodName = 'No method "%s" was found.'; + SErrInvalidClassMethodName = 'No class "%s" with method "%s" was found.'; + SErrDuplicateJSONRPCClassHandlerName = 'Duplicate JSON-RPC handler for class "%s" with method "%s".'; + SErrDuplicateJSONRPCHandlerName = 'Duplicate JSON-RPC handler for method "%s".'; + SErrUnknownJSONRPCClassMethodHandler = 'Unknown JSON-RPC handler for class "%s", method "%s".'; + SErrUnknownJSONRPCMethodHandler = 'Unknown JSON-RPC handler for method "%s".'; + SErrDuplicateRPCCLassMethodHandler = 'Duplicate JSON-RPC handler for class "%s", method "%s".'; + SErrDuplicateRPCMethodHandler = 'Duplicate JSON-RPC handler for method "%s".'; + SErrNoDispatcher = 'No method dispatcher available to handle request.'; + SErrUnknownMethodForClass = 'unknown method name for class %s: %s'; + SErrCreatorDoesNotSupportInterface = 'Creator does not support interface %s'; + +implementation + +end. + diff --git a/packages/fcl-web/src/jsonrpc/webjsonrpc.pp b/packages/fcl-web/src/jsonrpc/webjsonrpc.pp index 1b30d27993..8647bb2e6f 100644 --- a/packages/fcl-web/src/jsonrpc/webjsonrpc.pp +++ b/packages/fcl-web/src/jsonrpc/webjsonrpc.pp @@ -147,9 +147,9 @@ type implementation -{$ifdef debugjsonrpc} -uses dbugintf; -{$endif} + +uses {$ifdef debugjsonrpc}dbugintf,{$endif} fprpcstrings; + Const SApplicationJSON = 'application/json';