WCF

WCF SOAP Message Version

Service and client communicate to each other through Messages. So they must be agreed upon the Message version while communicating. Service may send Message as POX or may be as SOAP12.

When at service side we create a SOAP Message, we term it as Message Object Model. Essentially, we can say Message Object Model is used to create SOAP Message in WCF to communicate with client. When we create SOAP Message, we specify the Message Version and it is not amendable afterwards.

Message created using Message Object Model essentially consists of Envelope versions and Addressing version type.

 

image

 

MessageVersion class is inside System.ServiceModel.Channels. If you navigate to MessageVersion class you would find AddressingVersion and EnvelopeVersion there.

 

image

Different Message versions are as below

image

If you want you can create your own Message Version

image

 

CreateVersion is overloaded function. Either you can pass only Envelope Version or Envelope Version and Addressing Version both to create your own Message Version.

Now let us go ahead and inspect the entire Message version to find what Envelope Version and AddressingVersion type are inside a particular Message Version.

 


using System;
using System.ServiceModel.Channels;
namespace XML
{
    class Program
    {

        static void Main(string[] args)
        {
            MessageVersion version = MessageVersion.Default;
            Display(version ,"Default");
            version = MessageVersion.Soap11 ;
            Display(version,"SOAP11");
            version = MessageVersion.Soap11WSAddressing10 ;
            Display(version,"SOAP1110");
            version = MessageVersion.Soap11WSAddressingAugust2004;
            Display(version,"SOAPAddressingAuguest2004");
            version = MessageVersion.Soap12 ;
            Display(version,"SOAP12");
            version= MessageVersion.Soap12WSAddressing10;
            Display(version,"SOAP1210");
            Console.ReadKey(true);
        }

        static void Display(MessageVersion v , string strName)
        {
            Console.WriteLine(strName);
            Console.WriteLine("Addressing : " + v.Addressing.ToString());
            Console.WriteLine("Envelope : " + v.Envelope.ToString());
            Console.WriteLine();
        }
    }
}


 

If you run above code you will get output as below,

image

If you want to create a new Message Version, you can very much do that.

image

If you want you can pass as input parameter only EnvelopeVersion

image

Note: Display is a function to print EnevelopeVesrion and AddressingVesrion. This function is created previously in above code)

If you run above code you will get output as below

image

I hope now you are having some idea about SOAP Message Version. In next post, we will see more on Message in WCF.

I hope this post was useful. Thanks for reading Smile

About Dhananjay Kumar

Dhananjay Kumar is Developer, Blogger , Speaker, Learner , Mindcracker & Microsoft MVP.

Discussion

3 Responses to “WCF SOAP Message Version”

  1. Man, if you’re communicating between Windows clients or tiers SOAP is great, but it can be a pain in the ass when you’re connecting multiple client types for that data consumption. I will jump through just about any hoop possible to offer secure POX services.

    Nice write up though!

    Posted by Ian Patrick Hughes | June 14, 2011, 10:32 pm

Trackbacks/Pingbacks

  1. Pingback: Create Message in WCF | DEBUG MODE...... - June 15, 2011

  2. Pingback: Monthly Report June 2011: Total Posts 33 « debug mode…… - December 4, 2011

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,380 other followers

Tweets

Categories

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my current or previous employer's view in anyway. © Copyright 2012