0 Replies Latest reply on Mar 31, 2010 4:58 AM by oanguenot75

    Flex 4 and WebService/HttpService with encoding = chunked

    oanguenot75

      Hello,

       

      I try to connect my Flex/AIR application to a WebService that keep the socket open to send notification (push event data to the client).

       

      I have tried with the WebService object and with an HttpService object but without success. Using TCP Tunnel/Monitor, I can see that the response is correclty received, but in Flex Network monitor, there is no response displayed.

      --> It seems to be correct, because the socket is not closed.

       

      But my question is how to be notified and to handle these data that can be pushed from the server at any time.

       

      Here is an extract of my code using WebService:

       

      var appService:String = "OXOWebServices";

      var opeLogin:Operation = myWebService.getOperation("startSubscribeApp") as Operation;
      opeLogin.addEventListener(FaultEvent.FAULT, subscribeAppErrorCallback);
      opeLogin.addEventListener(ResultEvent.RESULT, subscribeAppResultCallback);
      opeLogin.send(appService);

       

      -> The two callback are never called

       

      Using HTTPService:

       

      var test:HTTPService = new HTTPService();

      test.contentType = "application/xml";           
      var header:Object=new Object();
      header["SOAPAction"]= "startSubscribeApp";
      header["Keep-Alive"]= "300";
      header["Connection"]= "keep-alive";
      header["Content-Type"] = "text/xml; charset=utf-8";
      test.headers=header;         
      test.method = "POST";
      var xml:XML = <SOAP-ENV:....>....</SOAP-ENV:Envelope>;
      test.request = xml;
      test.url = "...";
      test.addEventListener(ResultEvent.RESULT, testApp);
      test.addEventListener(FaultEvent.FAULT, testFaultApp);
      test.send(xml);

       

      --> The two callbacks are neved called

       

      --> How to treat "not finished" data coming from the server ?

       

      Here is an extract of the message exchanged with the server (seen using the TCP Tunner/Monitor tool) with a e_ping event pushed by the server

       

      1/ Request send to the server

       

      POST /services/XmlApp HTTP/1.1
      Referer: app:/Bees.swf
      Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, text/plain;q=0.8, text/css, image/png, image/jpeg, image/gif;q=0.8, application/x-shockwave-flash, video/mp4;q=0.9, flv-application/octet-stream;q=0.8, video/x-flv;q=0.7, audio/mp4, application/futuresplash, */*;q=0.5
      x-flash-version: 10,0,42,34
      Content-Type: text/xml; charset=utf-8
      SOAPAction: startSubscribeApp
      Keep-Alive: 300
      Content-Length: 471
      User-Agent: Mozilla/5.0 (Windows; U; fr-FR) AppleWebKit/526.9+ (KHTML, like Gecko) AdobeAIR/1.5.3
      Host: 127.0.0.1:5555

       

      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <SOAP-ENV:Body SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
          <tns:startSubscribeApp xmlns:tns="http://xmlapi.alcatel.com/app">
            <applicationId xsi:type="s:string">OXOWebServices</applicationId>
          </tns:startSubscribeApp>
        </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

       

      2/ Accept response sent by the server

       

      HTTP/1.1 200 OK
      Date: Wed, 31 Mar 2010 11:52:32 GMT
      Expires: Wed, 31 Mar 2010 11:52:32 GMT
      Content-Type: text/xml
      Transfer-Encoding: chunked

       

      261
      <?xml version="1.0" encoding="utf-8"?>
      <SOAP-ENV:Envelope
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <SOAP-ENV:Body>
      <ns1:startSubscribeAppResponse xmlns:ns1="http://xmlapi.alcatel.com/app" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      <result>
      <status>
      <code>0</code>
      <label>OK</label>
      </status>
      <subscribeId>10</subscribeId>
      </result>
      </ns1:startSubscribeAppResponse>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

       

      3/ Event pushed by the server

       

      1d6
      <?xml version="1.0" encoding="utf-8"?>
      <SOAP-ENV:Envelope
      xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
      xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
      xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance"
      xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <SOAP-ENV:Body>
      <ns1:e_ping xmlns:ns1="http://xmlapi.alcatel.com/app" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
      </ns1:e_ping>
      </SOAP-ENV:Body>
      </SOAP-ENV:Envelope>

       

      --> As chunked mode is used, header is not sent again

       

      So my question is how to handle such a case ?

       

      Is there an other way to receive these notification ?

       

      Thanks in advance,

      Olivier