Flash/flex with. NET Interop (ii): Data access based on WebService (top)

Source: Internet
Author: User
Tags wsdl

Flex provides <mx:WebService>, <mx:HTTPService> and <mx:RemoteObject> tags for direct access to remote data, which is used with a variety of different language It is easier to communicate the remote server data sources (such as WebService) provided by the environment development.

This article takes. NET platform under the C # language development WebService as a remote webservice, the detailed introduction of flex and. NET Data communication knowledge points webservice, including connection WebService, Remote Call WebService method, The WebService method is used to transfer parameters and other related knowledge points. The use of the three tags is basically the same, and here the <mx:WebService> tag as an example to introduce.

First look at the following code block:

1 <mx:WebService id="dataService"
2 wsdl="http://localhost/FlashFlex/DataWebService.asmx?wsdl"
3 useProxy="false">
4 <mx:operation name="HelloWorld" result="onSuccess(event)" fault="onFault(event)"/>
5 <mx:operation name="GetBook" fault="onFault(event)" result="onObjectSuccess(event) "/>
6 </mx:WebService>

The WSDL property specifies the WSDL address of the WebService to be accessed, which defines two action labels (<mx:operation>), respectively, corresponding to the WebMethod method defined in WebService. The result property tag accesses the successful handler function of the WebService method; fault, instead, specifies the handler function that accesses the failure. The above two <mx:operation> WebMethod methods corresponding to WebService are as follows:

1 /// <summary>
2 /// 返回字符串
3 /// </summary>
4 /// <returns></returns>
5 [WebMethod]
6 public string HelloWorld ()
7 {
8 return "Hello World";
9 }
10
11 /// <summary>
12 /// 返 回一个简单对象
13 /// </summary>
14 /// <returns></returns>
15 [WebMethod]
16 public Book GetBook()
17 {
18 return new Book
19 {
20 Id = 1,
21 Name = "三国演义",
22 Author = "罗贯中",
23 Price = 100
24 };
25 }

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.