1 Reply Latest reply: Dec 3, 2009 4:09 AM by sn1ckers RSS

    How to get amf headers?

    sn1ckers Community Member

      Hi

       

      I have set up communication between Actionscript and .NET WCF using amf. And the communication has worked fine using NetConnection. I have sent and recevied data in both directions. And sending headers from actionscript is no problem but when i send headers from WCF to actionscript I cant find a way to extract/find the header.

       

      I have monitored the call using charles and there I can se that the header is sent back with the call from WCF.

       

      I found this in the AMF specification, but how do i do it?

      To handle an AMF context header a suitable method needs to be available, matching the header name. NetConnection is now a sealed type so either it must be subclassed or an object with a suitable implementation needs to be set for the NetConnection client property.

       

      Thanks in advance

        • 1. Re: How to get amf headers?
          sn1ckers Community Member

          I solved it at posting my findings here.

           

          To get the header I had to send in a Object to the client parameter on NetConnection like the code below:

           

          public class UsingNetConnectionWithHeader

          {

               public function UsingNetConnectionWithHeader

               {

                    netCon = new NetConnection();

                    netCon.addEventListener(NetStatusEvent.NET_STATUS, connectionHandler);

                    netCon.connect(remotingGateway);

                    netCon.client = new CustomClient();

                    netCon.call("Method", new Responder(successfulResult, erroneousResult),param1,param2...);

               }

           

               public function connectionHandler(ev:NetStatusEvent):void

               {

                    if(ev.info.code == "NetConnection.Call.Failed")
                    {
                         trace("Call failed");
                    }

               }

           

               public function successfulResult(obj:Object):void
               {
                    trace("Call Successful");
               }

           

               function erroneousResult(obj:Object):void
               {
                   trace("Call Failed");
               }

          }

           

          public class CustomClient

          {

               public function CustomHeader(content:String):void

               {

                    trace("Got header with content:" + content);    

               }

          }

           

          To get this to work the custom header name must be CustomHeader.