1. Other consistent entry points for Web Services: int execute (Dataset DS );
2. Implement the non-chained factory model and dynamically load service providers to provide services.
1 Public Static Int Execute (Dataset DS) {
2
3 String [] Arr = Unpack (DS );
4
5 // Analysis and invoke right method
6 String Methodname = Arr [ 0 ]. Tostring (). Trim ();
7 Object [] Parme = New Object [] {
8System. int32.parse (ARR [1]. Tostring (). Trim ()),
9System. int32.parse (ARR [2]. Tostring (). Trim ())
10} ;
11
12 Assembly oassembly = Null ;
13 Type otype = Null ;
14
15
16 Oassembly = Assembly. getexecutingassembly ();
17 Otype = Oassembly. GetType (methodname );
18
19 Mycompute com = Null ;
20 Com = (Mycompute) activator. createinstance (otype );
21 // Omethod = otype. getmethod ("execute ");
22
23 // Int result = (INT) omethod. Invoke (new object (), Parme );
24 Int Result = Com. Execute (system. int32.parse (ARR [ 1 ]. Tostring (). Trim (), system. int32.parse (ARR [ 2 ]. Trim ()));
25 Return Result;
26 }
27
28 Public Static String [] Unpack (Dataset DS)
29 {
30 If (DS = Null ) Throw New Exception ( " Dataset Error " );
31
32 String [] Arr = New String [ 3 ];
33
34 Int I = 0 ;
35
36 Foreach (Datarow row In DS. Tables [ 0 ]. Rows)
37 {
38 Foreach (Datacolumn Column In DS. Tables [ 0 ]. Columns)
39 {
40Arr [I]=Row [column]. tostring ();
41I++;
42}
43 }
44 Return Arr;
45 }
46
3. The client obtains the service result through ajax to achieve no refreshing.
[Ajax. ajaxmethod ()]
Public int getresult (string methodname, string str1, string str2)
4.
1 Function serverside ()
2 {
3 _ Default. getresult (
4 Document. getelementbyid ( " Select1 " ). Value,
5 Document. getelementbyid ( " Text1 " ). Value,
6 Document. getelementbyid ( " Text2 " ). Value, serverside_callback );
7 }
8
9 Function serverside_callback (RES) {
10 // Document. getelementbyid ("result"). value = response. value;
11 If (Res. Error ! = Null ) Alert (res. Error );
12
13 Document. getelementbyid ( " Result " ). Innerhtml = " <Font size = 3 color = Red> " + Res. Value + " </Font> " ;
14
15 }