[Reprinted red fish] kbmmw development: Authorization failed.

Source: Internet
Author: User

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;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.