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.