Welcome to Windows Communication Foundation (WCF)
Top Tasks :

WCF Team Bloggers

Mystery of the Disappearing Addressing Headers

Why do the messages logged by my service show addressing headers but those headers disappear when the message is sent? This is easy to explain once you actually look at the messages. Here's a quick test program that generates some SOAP 1.1 messages with all of the different addressing permutations. using System; using System.Collections.Generic; using System.ServiceModel.Channels; using System.Xml; class MyBodyWriter : BodyWriter { public MyBodyWriter() : base ( true ) { } protected override void OnWriteBodyContents(XmlDictionaryWriter writer) { } } class Program { static IEnumerable<MessageVersion> Versions { get { yield return MessageVersion.Soap11; yield return MessageVersion.Soap11WSAddressing10; yield return MessageVersion.Soap11WSAddressingAugust2004; } } static void Main( string [] args) { foreach (MessageVersion version in Versions) { Message m = Message.CreateMessage(version, "http://MyApplication/Action" , new MyBodyWriter()); m.Headers.To = new Uri( "http://localhost/service" ); Console.WriteLine( "MessageVersion: {0}\n{1}\n" , version, m.ToString()); } Console.ReadLine(); } } That generates the following set of messages: MessageVersion: Soap11 (http://schemas.xmlsoap.org/soap/envelope/) AddressingNone (http://schemas.microsoft.com/ws/2005/05/addressing/none) < s:Envelope xmlns:s ="http://schemas.xmlsoap.org/soap/envelope/" > < s:Header > < Action s:mustUnderstand ="1" xmlns ="http://schemas.microsoft.com/ws/2005/05/addressing/none" > http://MyApplication/Action </ Action > < To s:mustUnderstand ="1" xmlns ="http://schemas.microsoft.com/ws/2005/05/addressing/none" > http://localhost/service </ To > </ s:Header > < s:Body /> </ s:Envelope > MessageVersion: Soap11 (http://schemas.xmlsoap.org/soap/envelope/) Addressing10 (http://www.w3.org/2005/08/addressing) < s:Envelope xmlns:a ="http://www.w3.org/2005/08/addressing" xmlns:s ="http://schemas.xmlsoap.org/soap/envelope/" > < s:Header > < a:Action s:mustUnderstand ="1" > http://MyApplication/Action </ a:Action > < a:To s:mustUnderstand ="1" > http://localhost/service </ a:To > </ s:Header > < s:Body /> </ s:Envelope > MessageVersion: Soap11 (http://schemas.xmlsoap.org/soap/envelope/) Addressing200408 (http://schemas.xmlsoap.org/ws/2004/08/addressing) < s:Envelope xmlns:a ="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:s ="http://schemas.xmlsoap.org/soap/envelope/" > < s:Header Read More...
Published Tuesday, March 18, 2008 8:00 AM by Nicholas Allen's Indigo Blog
Filed under: , ,

Comments

No Comments
Anonymous comments are disabled

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us