I LOVE C#

Eyal Vardi

Experts4D

  • Eyal Vard

Firefox Extensions

Post News

June 2008 - Posts

Obtaining an Untyped WCF Message from a Typed Service Operation

 

OperationContext.Current.RequestContext.RequestMessage

To see the information in WCF Service Visualizer

 

ocv_2

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.

WCF Tools

WCF Tools & Links:

1. Managed Services Engine (MSE)

2. WCF Live Service Trace Viewer

3. WCF Visualizer

4. Web Service Software Factory (wssf)

5. Keystroke ESB.NET

6. DinnerNow.NET Sample Application

7. MSDN WCF Tools Page

8. WCF Load Test

More Posts