2 Replies Latest reply on May 8, 2008 7:02 AM by 99Dev

    handle multiple output parameters returned from a .net webservice method in flex 2

      Does anyone know if flex application will be able to handle multiple output parameters from a .net webservice method? I can easily get the response I want, when a web service is returning only 1 output parameter. all output parameters are of type string having valid xml.

      Web Service Code:
      public string GetUserList(string strUserName, out String UserListXml)
      String ErrorXml = null;
      //call to next layer which returns User list in xml format in 'UserListXml' value or ErrorXml if any
      //e.g. UserListXml = <UserCollection><User>1</User></UserCollection> and ErrorXml = null
      //Or UserListXml = null and ErrorXml = <ErrorCollection><Error>Get data error</Error></ErrorCollection>
      return ErrorXml;

      Flex application code:
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns="*"
      <mx:WebService id="TestWS" showBusyCursor="true"
      wsdl=" http://localhost/ALServices/TestWS.asmx?WSDL" useProxy="false" load="AddCommonheader();">
      <mx:operation name="GetUserList"

      import mx.rpc.soap.SOAPHeader;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      import mx.collections.XMLListCollection;

      public var __xlCollList:XMLListCollection;

      private function GetProductDetails_Result_New(objEvent:ResultEvent):void
      __xlCollList = new XMLListCollection((XML(myTestService.GetUserList.lastResult)).USER);

      private function GetALProductDetails_fault(objEvent:FaultEvent):void
      Alert.show(objEvent.fault.message, ":Fault");

      <mx:Panel id="Panel1" width="100%" height="654" y="10">
      <mx:DataGrid id="dGrid1" dataProvider="{__xlCollList}" width="616" height="171"
      editable="false" selectable="false" sortableColumns="true">
      <mx:DataGridColumn headerText="User Name" dataField="USERNAME"/>
      <mx:DataGridColumn headerText="Address" dataField="ADDR"/>
      <mx:DataGridColumn headerText="Status" dataField="STATUS"/>

      if I specify resultFormat="object" , I will get xml value corresponding to 'ErrorXml' parameter.
      and when I specify resultFormat="e4x" , I will get xml structure for result but value corresponding to 'UserListXml' parameter is returend as plain string
      e.g: <User>1</User> is returned as &lt;User&gt;1&lt;/User&gt;

      please help me out!
      Thanks in advance.

        • 1. Re: handle multiple output parameters returned from a .net webservice method in flex 2
          batmitra Level 1
          the short answer for your question is yes, flex can handle multiple output parameters.

          Now the fun part, the best way to work with flex and .net is to use what is called a data transfer object wich means you should be using arraylists to pass an array of classes from .net and put it together on flex as an array collection too. I don't have here code for you by try search google for data transfer objects. I work with them a lot and it works with .net 1.1 or above framework.

          As for your application, you are sending your result from .net to flex as a String so that's why flex treats it as a string when you put it as E4X because you are not retuning a valid XML format. As an object you get better results.

          • 2. Re: handle multiple output parameters returned from a .net webservice method in flex 2
            99Dev Level 1
            Thanks a lot.
            But as this web service is third party component its not possible for me to change its sytanx. I need to access this as it is from flex 2.
            I am not getting How to use data transfer object in this scenario.
            Can you please explain with some example?
            It would be a gr8 help.