I LOVE C#

Eyal Vardi

Experts4D

  • Eyal Vard

Firefox Extensions

Post News

How to get implementation of IDispatchMessageFormatter

 class E4DBehaviorAttribute : Attribute , IOperationBehavior

    {

        #region IOperationBehavior Members

 

        public void AddBindingParameters (

            OperationDescription operationDescription ,

            BindingParameterCollection bindingParameters )

        {

        }

 

        public void ApplyClientBehavior (

            OperationDescription operationDescription ,

            ClientOperation clientOperation )

        {

        }

 

        public void ApplyDispatchBehavior (

            OperationDescription operationDescription ,

            DispatchOperation dispatchOperation )

        {

            DataContractSerializerOperationBehavior SerializerBehavior =

                operationDescription

                    .Behaviors.Find<DataContractSerializerOperationBehavior>();

 

            if ( dispatchOperation.Formatter == null )

            {

                ((IOperationBehavior)SerializerBehavior)

                    .ApplyDispatchBehavior (

                        operationDescription , dispatchOperation );

            }

            IDispatchMessageFormatter innerDispatchFormatter =

                                        dispatchOperation.Formatter;

 

 

            // Create Empty Message with IDispatchMessageFormatter

            Message msg = innerDispatchFormatter

                           .SerializeReply(

                            MessageVersion.Soap12 , new object[]{} , null );

 

            Console.WriteLine ( msg.ToString() );

        }

 

        public void Validate ( OperationDescription operationDescription )

        {

        }

 

        #endregion

    }

 

Tip: Download WCF Visualizers.

Comments

Sreen Sunki said:

Nice work around :-)

# August 9, 2011 2:31 PM

Aranda said:

Hello there I am so glad I found your blog page, I actually found you by mistake, while I was searching on Bing for something else, Anyways I am here now and

would just like to say thanks a large amount for a marvelous post and a all round entertaining blog (I also love that the theme/design),

I donít have time to browse it all at that the moment but

I have book-marked it and also included your RSS feeds,

so when I have time I will be back to read more, Please do keep up the awesome

job.

# January 13, 2013 1:16 PM
Leave a Comment

(required) 

(required) 

(optional)

(required)