flex How to call a custom class in WebService, here's a good example, and friends who don't know can refer to the following
The code is as follows: public class returnresult { public int Curindex {get; set;} Public DataTable idxlist {get; set;} } //test database connection [WebMethod (Description = "!!! Test database connection, link string in Web.config ")] public bool Conectdb () { Strcon = configurationsettings.appsettings[" Sqlconduke "]; conn = new SqlConnection (Strcon); try , { . Open (); return true; } catch (Exception) { return false; } finally {  ; Conn. Close (); } } code is as follows: [WebMethod (Description = "Get detailed data (DataTable) based on <b> photo name </b>, STRTB , eg:panview;strimgname,eg:20131019072740-0000150 ")] public DataTable getinfobyimgname (string STRTB, String Strimgname) { bool Ifcon = CONECTDB (); if (Ifcon) { string sql_bfcar = "SELECT * FROM dbo." + STRTB + "where imagename like '%" + strimgname + "% '"; da = new SqlDataAdapter (SQL_BFCAR, conn); myds = NE W DataSet ();nbsp Da. Fill (myds); return myds. tables[0]; } else { return null; } } [WebMethod (Description = "Based on <b> photo name </b> get all the data (returnresult) of the link, strtb,eg:panview;strimgname,eg:20131019072740-0000150 ")] Public Returnresult Getlinkdtbyimgname (string strtb, String strimgname) { Returnresult Returnresult = New Returnresult (); bool Ifcon = CONECTDB (); if (ifcon) { Returnresult.curindex = Convert.ToInt32 (Getinfobyimgname (STRTB, Strimgname). Rows[0][0]); string strlinkguid = Getinfobyimgname (STRTB, Strimgname). ROWS[0][1]. ToString (); String sql_bfcar = "SELECT * FROM dbo." + STRTB + "where linkguid like '%" + strlinkguid + "%" "; da = new SqlDataAdapter (SQL_BFCAR, conn); myds = new DataSet (); da. Fill (myds); returnresult.idxlist = myDS. tables[0]; return returnresult; } else { return null; } } Flex CodeThe: code is as follows: <?xml version= "1.0" encoding= "Utf-8"?> <s:application "xmlns:fx=" http://ns.adobe.com/ mxml/2009 " xmlns:s=" Library://ns.adobe.com/flex/spark " xmlns:mx=" LIBRARY://NS.ADOBE.COM/FLEX/MX " Minwidth= "955" minheight= "creationcomplete=" Application1_creationcompletehandler (event) > <FX: script> <! [cdata[ Import mx.collections.arraycollection; Import mx.controls.alert; Import mx.events.flexevent; Import mx.rpc.events.faultevent; Import mx.rpc.events.resultevent; public var arr:arraycollection=new arraycollection (); public var aaa:string=new String (); protected function Webservice1_faulthandler (event:faultevent):void { alert.show (event.fault.toString ()); } protected function Getlinkdtbyimgnamehandler (event:resultevent):void { //aaa= this.myweb.getlinkdtbyimgname.lastresult.curindex; //Arr=this.myweb.getlinkdtbyimgname.lastresult.idxlist.tables.table.rows; aaa=event.result.curindex; arr= event.result.idxlist.tables.table.rows; alert.show (aaa+ "" +arr.length.tostring ()); } protected function Application1_creationcompletehandler (event:flexevent):void { Myweb.getlinkdtbyimgname ("Panview", "20131019072740-0000150"); } ]]> </fx:Script> <fx:Declarations> <!--place non-visual elements (such as services, value objects) here--> <s:webservice id= "MyWeb wsdl=" http ://10.19.1.55/serverpano/webserviceduke.asmx? WSDL "fault=" Webservice1_faulthandler (event) "> <s:operation name=" Getlinkdtbyimgname "result=" Getlinkdtbyimgnamehandler (Event) "></s:operation> </s:WebService> </fx:declarations > </s:Application>