Vs.net created by flash webservice + Simple Calculator
'=====================
'Reprint requests to retain the following information
'Originality: Ouyang Jie East
'Http://www.cnsxml.com
'=====================
Read this guide, you will find that the webservice. Net really very simple!
We should take advantage of vs.net create a simple webservice, his function is a simple four computing.
Then create a flash to call this webservice
First, create WEBSERVICE
1. Opened Visual Studio. NET.
2. Creation of a new Active Server Pages (ASP). NET Web services. The Web service named OydjService and, when necessary, be designated as a suitable location
When the operation ASP.NET Web server.
3. Solution document will change the name of OydjService to maintain consistency.
4. Service1.asmx will be used to create the default Web services to change the name of OydjService.asmx.
5. Click design environment in the Click here to view the code to switch to switch to code view.
6. Used to package your definition of the functions of the service. This service provides a way ahead for each must be marked with a WebMethod attribute. Without this property, this service will not be open
Methods.
Note: not every one of the ways we need to have WebMethod attribute. Hide from the common method called Web services to achieve certain details is very useful in the local application process is also used
WebService such circumstances, the need to achieve some hidden details. Local applications can use any common category, but only a WebMethod attribute method can be used as Web
Remote Access service.
The following code will be added to the front of your creation in the OydjServices categories:
Code: <WebMethod()> Public Function Add (a As Integer, b As Integer) As Integer
Return (a + b)
End Function
<WebMethod()> Public Function Subtract (A As System.Single, B As System.Single) As System.Single
Return A - B
End Function
<WebMethod()> Public Function Multiply (A As System.Single, B As System.Single) As System.Single
Return A * B
End Function
<WebMethod()> Public Function Divide (A As System.Single, B As System.Single) As System.Single
If B = 0
Return -1
End If
Return Convert.ToSingle (A / B)
End Function
Generation Web Services: From Generation menu, select generation.
OydjService.asmx Web can be transferred to the service to test this Web page services. If you placed in the pages on the local computer, then URL is
Http://localhost/OydjService/OydjService.asmx.
Running ASP.NET will return to a Web page services help to illustrate this Web service. This page also allows you to test different methods of Web services.
Second, to create FLASH call this WEBSERVICE
1. A new flash
2. Into two text boxes (textarea), named respectively: t1, t2
3. Dragged into the drop-down menu (comboBox), named: ysf, and to add "data" attribute: "[1,2,3,4]," and "Labels" attribute :"[+,-,*, ÷] "
4. Dragged into a dynamic text box named: convert
5. Dragged into a button (button), named as: search
6. Components into a webserviceConnector
7. In the first frame editorial "moves" by adding the following code
Code: import mx.services .*;
/ / Set wsdl Address
Var wsdlURI = "http://localhost/OydjService/OydjService.asmx?WSDL";
Ws = new WebService (wsdlURI);
/ / Point of a button and connect ws calculation
Search.onPress = function () (
/ / Computing
Switch (ysf.selectedItem.data) (
Case 1:
Callback = ws.Add (t1.text, t2.text);
Break;
Case 2:
Callback = ws.Subtract (t1.text, t2.text);
Break;
Case 3:
Callback = ws.Multiply (t1.text, t2.text);
Break;
Case 4:
Callback = ws.Divide (t2.text, t1.text);
Break;
)
/ / Web services successfully sent back information
Callback.onResult = function (result) (
Convert.text = result;
)
/ / Web services back to the wrong information
Callback.onFault = function (fault) (
For (i in fault) (
Trace (i + ":" + fault [i]);
)
)
)
3, demonstration
Tags: webservice








0 Comments to “Vs.net created by flash webservice + Simple Calculator”
No Comments. Send your comment.
Leave a Reply
You must be logged in to post a comment.