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.
MessageVersion class is inside System.ServiceModel.Channels. If you navigate to MessageVersion class you would find AddressingVersion and EnvelopeVersion there.
Different Message versions are as below
If you want you can create your own Message Version
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,
If you want to create a new Message Version, you can very much do that.
If you want you can pass as input parameter only EnvelopeVersion
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
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
Leave a Reply