1 Reply Latest reply on Jul 23, 2007 10:20 AM by ntsiii

    How to get webservice result as "e4x" format in a professional solution?

      Hi. I want to get data from a .Net webservice as "e4x" format. It works when i use <mx notation to define the service in flex. However i want to build a more professional solution and want to implement the webservice as a class. But I can't get it to work such that i return the result as "e4x". Instead i get an object with arrays etc. The problems might be that i need to use the flex class operation to define "e4x" and then i need to bind the operation with the webservice but it seems that the webservice still doesn't know about to return the result as e4x. Here you see the code in <mx notation which is working fine:

      <mx:WebService id="WS" wsdl=" http://localhost/testservice/service.asmx?WSDL"
      result="WS_onResult(event)" >
      <mx:operation name="HelloWorld" resultFormat="e4x" >

      And in the WS_onResult procedure i get the result by doing this:
      var xmlResult:XML = XML(event.result);

      As i said the above code is working fine but the code below doesn't work well because it doesn't return the result as "e4x":

      WS = new mx.rpc.soap.WebService();
      WS.wsdl = " http://localhost/testservice/service.asmx?WSDL";
      WS.addEventListener(LoadEvent.LOAD, load_listener);
      WS.addEventListener(ResultEvent.RESULT, result_listener);
      OP = new mx.rpc.soap.Operation(WS,"HelloWorld");

      And in the load procedure to perform the call:

      public function load_listener(event:LoadEvent):void {
      OP.resultFormat = "e4x";

      And in the result listener i get a result as object and NOT as "e4x". Can anyone help?

      Btw. here i add the .Net code:

      public XmlElement HelloWorld() {
      XmlDocument doc = new XmlDocument();
      string xml = "<Test>this is a test</Test>";
      return doc.DocumentElement;