Build asp.net Webservice for Flash

Source: Internet
Author: User
Tags wsdl

It seems that my action is the slowest, the flower fire has written the ColdFusion WebService, the hero also took care of the Java WebService. Anyway, it's still to be written. I don't want to repeat anything about soap, WSDL, and UDDI. Now to do a very simple Web service, but also very boring. To run the. NET program, you must first install the. NET Framework again, because the program calls the base class of the framework. Is that you enter a number n, and the server calculates the value of the nth item in the Fibonacci number sequence that returns this number.

You do not know this series of computer science? I faint! Well, here's the Fibonacci introduction (Copy over)

Fibonacci (Fibonacci is an Italian mathematician, about 11,701 to 1250 years) the sequence is caused by a "rabbit problem", namely:

Suppose a pair of big rabbits can give birth to a small rabbit every one months, and the rabbit has a reproductive ability two months after birth. How many pairs of rabbits can be bred in a year from the start of a pair of big rabbits? This produces the Fibonacci series:

1,1,2,3,5,8,13,21,34 ...

The rule is from the third, each of which is the first two. The expression of a recursive formula is

A1=a2=1,

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

OK, I got it, keep on the road. We have to achieve the above function, write a webservice program, tube You use what software editing, with Notepad can be. As follows:

Code Copy Box
<%@ Webservice Language="C#" class="Fibonacci" %>
using System.Web.Services;
public class Fibonacci:WebService
{
[WebMethod]
public int GetSeqNumber(int fibIndex)
{
if(fibIndex<2)
return fibIndex;
int[] FibArray={0,1};
for(int i=1;i<fibIndex;i++)
{
FibArray[1]=FibArray[0]+FibArray[1];
FibArray[0]=FibArray[1]-FibArray[0];
}
return FibArray[1];
}
}

[Ctrl + a All select and copy]

Then save it as a fibonacci.asmx., the suffix is named asmx. When you visit Http://localost/fibonacci.asmx with IIS, you go to the Fibonacci help page. As shown in the figure:

Click on the first line of service description to enter the Web Service description page, which is the WSDL page Http://localhost/fibonacci.asmx?WSDL. As shown in the figure:

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.