Using amf header

Nov 30, 2009 at 1:49 PM

Hi! I will have to start to say that this is really nice work.

I started a project where i use Actionscript 3.0 and a WCF with amf endpoint. And i have got it to work, to send object and receive objects. But I run into trouble when I started to use AMF headers. First of is that I can't get the example(Example5) to work and the second is that I can't find the header im sending in from Actionscript when the call come to WCF. Have anyone bumped into this problem and fixed it?

I will continue to search for a solution, ill be in touch if I find one.

Coordinator
Nov 30, 2009 at 4:19 PM

Thanks for the compliment - I appreciate it! 

Unfortunately, I haven't done any AS3 work with this project yet, so you're on your own for now.  As soon as we do, I'll be happy to post any of my findings. 

Good luck!

 

Dec 1, 2009 at 6:30 AM
Edited Dec 2, 2009 at 1:06 PM

I got the example5 to work with WCF client, the thing was that the web reference needed to be updated. I have not got the example5 to worked with AS 3.0 yet. But one thing that's confusing me is that the header is a sub object of MathParamters, shouldn't it be a stand alone object?

 

Coordinator
Dec 14, 2009 at 1:53 PM

Sorry I just saw this message, sn1ckers. 

I found that WCF works best with strongly-typed headers as part of the message contract, especially if you want the headers to act as required.  Otherwise, headers should be treated as additional information, according to the SOAP protocol.  (And since that's what WCF was modelled after, they made it a real pain to do anything different.)  WcfFlashRemoting can only recognize strongly-typed objects, so you'll have to specify that the header is associated with the message in some way.

Let me know if there's anything else I can help with.

 

Feb 17, 2010 at 7:53 AM

I got a question if I got this to work in WCF. And the answer is yes.

 

I use the header like a default header that is sent with each message in and out. I have a special behavior that reads the header when I recive it.

 

in function AfterReceiveRequest

AmfMultipleMessage msg = OperationContext.Current.RequestContext.RequestMessage as AmfMultipleMessage;

            string value = string.Empty;

            foreach (var header in msg.AmfHeaders)
            {
                if (header.Name == HeaderName && header.Content != null)
                {
                    NamedDictionary namedData = header.Content as NamedDictionary;
                    foreach (KeyValuePair<string, object> kvp in namedData.Properties)
                    {
                        switch (kvp.Key.ToLower())
                        {
                            case "valeu":
                                value = (string)kvp.Value;
                                break;
                            default:
                                break;
                        }
                    }
                }
            }

            return value;

 

and in function BeforeSendReplay I set the header like this:

AmfMultipleMessage msg = reply as AmfMultipleMessage;
            if (msg != null)
            {
                var responseHeader = new ResponseHeader();
                responseHeader.Name = "responseHeader";
                responseHeader.Content = some value;
                responseHeader.MustUnderstand = true;

                msg.AmfHeaders.Add(stateHeader);
            }

 

and I changed the Headers from a array to a list in the framework, for easier access and modification.

Hopes this help you :-)

Oct 26, 2010 at 8:45 AM

Hi,

I can´t reproduce this code, mainly because this line:

AmfMultipleMessage msg = OperationContext.Current.RequestContext.RequestMessage as AmfMultipleMessage;

In the dll that I downloaded in this site, the type AmfMultipleMessage is internal, so that can't be used in my code.

Someone can help me?

Thanks in advance.