Flex vs. NET Interop (iii): Data access based on WebService (next)

Source: Internet
Author: User

In the previous article flex and. NET Interop (II): Based on WebService data Access (upper), the <mx:WebService> tags are introduced to access WebService. In fact, we can also dynamically access the Webservice,flex SDK programmatically to provide us with the WebService class.

Using the WebService class to access WebService actually means that the properties of the <mx:WebService> tag are represented by the properties of the class object, compared with the WebService analogy using the <mx:webservice > Label to be flexible. Let's look at how to connect and invoke a remote method programmatically:

1 internal function onClick():void
2 {
3 var service:WebService = new WebService();
4 service.loadWSDL ("http://localhost:1146/FlashFlexService.asmx?wsdl");
5 service.addEventListener (ResultEvent.RESULT,onResult);
6 service.addEventListener(FaultEvent.FAULT,onFault);
7 service.GetBook ();
8 }

Call the remote webservice directly through the LOADWSDL () method of the class object, dynamically assigning the related handler function to the class object, and then calling the remote WebService method as the label can.

1 internal function onResult(evt:ResultEvent):void
2 {
3 Alert.show(evt.result.Id);
4 }
5
6 internal function onFault(evt:FaultEvent):void
7 {
8 Alert.show (evt.fault.faultDetail.toString());
9 }

The call to access the remote WebService method programmatically using the WebService class is completed as above.

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.