Start to use kbmmw for project implementation. The first thing is to add user authentication to the server. If a request sent from the client cannot pass authentication on the server, that is, the client fails to authenticate, an error message window is displayed on the client: Authorization failed. users cannot see such prompts. You have to find a way to intercept such errors and give your own prompts. Unexpectedly, after a weekly split, we finally found that kbmmw did not provide a mechanism to deal with such problems.
First, let's see where the server handles such errors:
Unit: kwmmwserver
Method: Procedure tkbmmwserver. internalservemessagepart
'Authorization failed .')
Row number:
The server directly writes the error to the returned stream. It is obvious that the author did not think of the problem of multiple languages.
Check the client again:
Unit: kbmmwclient
Method: function tkbmmwcustomclient. internalsendrequest
Code:
If tresponsestream. iserror then
Begin
Case tresponsestream. statuscode
-Kbmmw_err_authfailed: Raise
Ekbmmwauthexception. Create (kbmmw_err_authfailed, tresponsestream. statustext );
Row: 864
If the client directly determines that the returned stream is incorrect, the raise server returns an error message!
Solution:
1. Change the error message to Chinese characters.
2. Modify the source code in tkbmmwcustomclient, add events, and support error handling.
3. customize it in the server kbmmwserver. onserverresponse event.
Procedure tform1.kbmmwserver1serveresponse (Sender:
Tobject;
Outstream: ikbmmwcustomresponsetransportstream;
Service: tkbmmwcustomservice;
Clientident: tkbmmwclientidentity; ARGs:
Tkbmmwvariantlist );
Begin
With outstream do begin
Case statuscode
-Kbmmw_err_authfailed: statustext: = 'user identity cannot be confirmed by the server ';
-Kbmmw_err_funcnotavail: statusstext: = 'service unavailable ';
-Kbmmw_err_abort :;
-Kbmmw_err_servicenotavail :;
End;
End;
End;