Flash Builder 4 + WebService

Source: Internet
Author: User

Using vs2008 + flash Builder 4

1. Use vs to create a website and add a web service.

File: WebService. asmx

Using system; using system. collections. generic; using system. LINQ; using system. web; using system. web. services; //< summary> // Summary of WebService /// </Summary> [WebService (namespace = "http://tempuri.org/")] [webservicebinding (conformsto = wsiprofiles. basicprofile1_1)] // to allow ASP.. Net Ajax calls this web service from a script. uncomment the following lines. // [System. web. script. services. scriptservice] public class WebService: system. web. services. webService {public WebService () {// If the designed component is used, uncomment the following line // initializecomponent ();} [webmethod] Public String helloworld () {return "Hello World ";}}

Set WebService. asmx as the start page and click Start. Http: // localhost: 52000/WebService. asmx

See

The following operations are supported. For formal definitions, see service description.

  • Helloworld

Indicates that the Web Service is successfully started.

2. Flash Project

After adding a project, add a button to add a click event

Modify the <FX: declarations> node

<FX: declarations>
<! -- Place non-visual elements (such as services and value objects) Here -->
<Mx: WebService id = "dataservice" WSDL = "http: // localhost: 52000/WebService. asmx? WSDL "useproxy =" false ">
<Mx: Operation name = "helloworld" result = "onsuccess (event)" fault = "onfault (event)"/>
</MX: WebService>
</FX: declarations>

Add three functions,

(Protected function button#clickhandler (Event: mouseevent): void is generated when you click an event)

Internal function onsuccess (EVT: resultevent): void {trace (EVT. result. tostring ();} internal function onfault (EVT: faultevent): void {trace ("failed to access WebService! ");} Protected function button#clickhandler (Event: mouseevent): void {trace (" click "); dataservice. helloworld ();}

Click the button to view the flash builder console.

 

Click

Hello World

At this point, the Web Service is successfully called.

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.