Construct asp.net Webservice for flash

Source: Internet
Author: User

It seems that my actions are the slowest. huafang has already written the ColdFusion Webservice, and Xiaojie has also completed the java WebService. No matter whether it is, it is still to be written. I don't want to repeat anything about soap, wsdl, and uddi. Now it's boring to make a simple Web service. To run the. net program, install the. net framework first, because the program needs to call the base class of the framework. That is, you enter a number N, and then the server calculates the value of the nth entry in the Fibonacci number series of the number.

Do you know this series when you study computer? I faint! Okay. Here is the introduction of Fibonacci (Copy)

The Fibonacci (Fibonacci is an Italian mathematician, about 1170-about 1250) series is caused by a "rabbit problem:

Suppose a big rabbit can have a rabbit every month, and the rabbit has reproductive ability two months after birth. How many rabbits can breed after a year from a big rabbit? In this case, the Fibonacci prize series will be generated:

, 34...

The rule starts from the third item. each item is the sum of the first two items.

A1 = a2 = 1,

An = an + 1 10 an-2 (n> = 3 ),

OK. To implement the above functions, we can write a WebService program, regardless of the software you use for editing and use NotePad. As follows:

Code copy box
<% @ Webservice Language = "C #" class = "Fibonacci" %> <br/> using System. web. services; <br/> public class Fibonacci: WebService <br/> {<br/> [WebMethod] <br/> public int GetSeqNumber (int fibIndex) <br/>{< br/> if (fiber index <2) <br/> return fiber index; <br/> int [] fiber array = {0, 1 }; <br/> for (int I = 1; I <fiber index; I ++) <br/>{< br/> fiber array [1] = fiber array [0] + fiber array [1]; <br/> fiber array [0] = fiber array [1]-fiber array [0]; <br/>}< br/> return fiber array [1]; <br/>}< br/>}
[Ctrl + A select all and copy]

Then save it as fibonacci. asmx. The suffix is asmx. Use IIS to visit http: // localost/fibonacci. asmx and go to the Fibonacci help page. :

Click Service Description in the first line of the body to enter the Web Service Description page, which is the WSDL page http: // localhost/fibonacci. asmx? WSDL. :

On the Help Page, GetSeqNumber is your service method. Click GetSeqNumber to go to http: // localhost/fibonacci. asmx? Op = GetSeqNumber. :

You can test the http post protocol in the parameter input box. For example, if you enter 10, the result is:

<? Xml version = "1.0" encoding = "UTF-8"?>
<Int xmlns ="Http://tempuri.org/">55</Int>

The answer is 55.

Below is the flash. First, create an interface. A total of four components need to be dragged into the scenario. Please refer to the following list.

Component Type

Instance name

Function

WebServiceConnector

Ws

Link to the WebService and bind data with the textInput and label components.

TextInput

Data

Input data n

Label

Answer

Returns the nth value of the Fibonacci series.

Button

Bt

Data trigger

After creation:

Click ws and use Alt + F7 to bring up the Component Property checker. Parameters defined in the parameter selection item:

Then define the input parameter and the result in Binding. :

OK, click params. Fiber index, and select the TextInput component instance data from Bind. :

Because the fibIndext parameter is obtained from the input box. Then define the Bind to of results and Bind it to the Label component instance answer. All data binding is complete.

Finally, add a command to the button (which is automatically generated by Baheviors for the reason-Lazy ):

On (click ){
This. _ parent. ws. trigger ();
}

Run Ctrl + Enter to test the operation!

Source code download

Related Article

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.