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

3 responses to “WCF SOAP Message Version”

  1. Ian Patrick Hughes

    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!

  2. […] In last post  we discussed about SOAP Message Versions. Now let us move ahead and create a Message. […]

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 )

Facebook photo

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

Connecting to %s

Create a website or blog at WordPress.com