Authentication when WS is called in Flash _ 6: Client

Source: Internet
Author: User
The WS end is described in detail, and the following is called on the client:


There is no difference between the calling method and the calling method of WS by common clients -- the underlying network transmission of the Flash Player SOAP Web service is always http post, and no special code needs to be written by the client for authentication. Therefore, any security methods (such as SSL) applied on the Flash HTTP transport layer can be supported through Web service calls in Flash. SSL/HTTPS provides the most common transmission security mode for SOAP message transmission, while http basic authentication is the most common Web site security mode at the transport layer and SSL.
The following code is used:
/// # Include "login."

Import mx. controls .*;
Import mx. services .*;
Import mx. transitions .*;
Import mx. transitions. easing .*;

Stop ();

Var myws: WebService = new WebService ("http: // localhost/claw/login. asmx? Wsdl ");

This. onLoad = function (){
Var t: Tween = new Tween (this, "_ alpha", Strong. easeIn, 0,100, 24 );
This. policyzm_txt.text = Math. round (Math. random () * 8999 + 1000 );
}

This. OK _bt.onPress = function (){
Var tmc: MovieClip = this. _ parent;
Var t: Boolean = false;
T = t | tmc. name_txt.text = "";
T = t | tmc. pw_txt.text = "";
T = t | tmc. yzm_txt.text = "";
If (t ){
Alert. show ("the user name, user password, or Verification Code cannot be null. Please check and enter it again !! ","...: Important:... ", 0, tmc, empty," icon_1 ", empty );
} Else {
If (tmc. yzm_txt.text <> tmc. policyzm_txt.text ){
Alert. show ("the verification code is incorrect. Please check it and try again !! ","...: Important:... ", 0, tmc, empty," icon_1 ", empty );
} Else {
// Call ws here to check user input
Var op_1: PendingCall = myws. checkUser (tmc. name_txt.text, tmc. pw_txt.text );
Op_1.onResult = t_login;
}

}

}

This. cancel_bt.onPress = function (){
Var tmc: MovieClip = this. _ parent;

Tmc. policyzm_txt.text = Math. round (Math. random () * 8999 + 1000 );
Tmc. pw_txt.text = "";
Tmc. yzm_txt.text = "";
Tmc. name_txt.text = "";
}

Function t_login (result ){
// Trace (result );
If (result = true ){
_ Root. play ();
} Else {
Alert. show ("the user cannot log on. Please try again !! ","...: Important:... ", 0, tmc, empty," icon_1 ", empty );
}
}

//// # Include "Test."
Import mx. services .*;

Stop ();

Var myws: WebService = new WebService ("http: // localhost/claw/admin. asmx? Wsdl ");

Function test (result ){
// Trace (result );
_ Root. test_txt.text = result;
}

This. wsTest_bt.onPress = function (){
Var op_1: PendingCall = myws. test ();
Op_1.onResult = test;
}

The above example is very simple. I just want to use it to explain the most basic process of how to process user authentication and authorization in WS and flash interaction in asp.net. Of course, according to actual needs, your code may be much more complicated than this.

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.