[Mono-dev] MessageHeader.GetUntypedHeader throw exception

Cocai simionato.cristiano at gmail.com
Thu Apr 21 05:26:14 EDT 2011


In a simple service like 
[ServiceContract]
public interface IMyService
{
	[OperationContract]
	void Request(Message msg);
}

if is added a System.ServiceModel.MessageHeader to the
System.ServiceModel.Channels.Message by typed header in this way: 

var msg = Message.CreateMessage(MessageVersion.Default,
"http://tempuri.org/IService/Request", "My Body");
var value = "TestHeader1";
var header = new MessageHeader<string>(value);
var h2 = header.GetUntypedHeader("HeaderName", "http://tempuri.org/");
msg.Headers.Add(h2);

when calling the service method Request(msg) in mono is throw an exception,
but if the header is added by:

var h2 = MessageHeader.CreateHeader("HeaderName", "http://tempuri.org/",
value );

without the use of typed header, all goes right.


The exception throw is:

System.ArgumentNullException has been thrown
"Argument cannot be null.
Parameter name: text"

at System.Xml.XmlBinaryDictionaryWriter.WriteString (System.String text)
[0x00006] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlBinaryDictionaryWriter.cs:719 
at System.Xml.XmlDictionaryWriter.WriteAttributeString (System.String
prefix, System.Xml.XmlDictionaryString localName,
System.Xml.XmlDictionaryString namespaceUri, System.String value) [0x00009]
in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.Runtime.Serialization/System.Xml/XmlDictionaryWriter.cs:166 
at System.ServiceModel.Channels.MessageHeader.WriteHeaderAttributes
(System.Xml.XmlDictionaryWriter writer,
System.ServiceModel.Channels.MessageVersion version) [0x0009a] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeader.cs:178 
at System.ServiceModel.Channels.MessageHeader.OnWriteStartHeader
(System.Xml.XmlDictionaryWriter writer,
System.ServiceModel.Channels.MessageVersion version) [0x00082] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeader.cs:131 
at System.ServiceModel.Channels.MessageHeader.WriteStartHeader
(System.Xml.XmlDictionaryWriter writer,
System.ServiceModel.Channels.MessageVersion version) [0x00000] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeader.cs:197 
at System.ServiceModel.Channels.MessageHeaders.WriteStartHeader (Int32
index, System.Xml.XmlDictionaryWriter writer) [0x0003e] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaders.cs:300 
at System.ServiceModel.Channels.MessageHeaders.WriteHeader (Int32 index,
System.Xml.XmlDictionaryWriter writer) [0x00016] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/MessageHeaders.cs:268 
at System.ServiceModel.Channels.Message.OnWriteMessage
(System.Xml.XmlDictionaryWriter writer) [0x00047] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:256 
at System.ServiceModel.Channels.Message.WriteMessage
(System.Xml.XmlDictionaryWriter writer) [0x00026] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/Message.cs:170 
at System.ServiceModel.Channels.BinaryMessageEncoder.WriteMessage
(System.ServiceModel.Channels.Message message, System.IO.Stream stream)
[0x0002a] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/BinaryMessageEncoder.cs:118 
at System.ServiceModel.Channels.TcpBinaryFrameManager.WriteSizedMessage
(System.ServiceModel.Channels.Message message) [0x00093] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpBinaryFrameManager.cs:389 
at System.ServiceModel.Channels.TcpDuplexSessionChannel.Send
(System.ServiceModel.Channels.Message message, TimeSpan timeout) [0x00076]
in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel.Channels/TcpDuplexSessionChannel.cs:150 
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.RequestCorrelated
(System.ServiceModel.Channels.Message msg, TimeSpan timeout, IOutputChannel
channel) [0x00006] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:587 
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00019] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:581 
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Description.OperationDescription od, System.Object[]
parameters) [0x00066] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:534 
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00038] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:499 
at System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00000] in
/usr/src/packages/BUILD/mono-2.10.1/mcs/class/System.ServiceModel/System.ServiceModel/ClientRuntimeChannel.cs:479


Is typed header unsupported? There is some other workaround to continue to
use typed header?

Thanks in advance.

Cristiano

--
View this message in context: http://mono.1490590.n4.nabble.com/MessageHeader-GetUntypedHeader-throw-exception-tp3465477p3465477.html
Sent from the Mono - Dev mailing list archive at Nabble.com.


More information about the Mono-devel-list mailing list