info

info

  • NA
  • 16
  • 0

MessageHeader WriteHeader Methode

Mar 16 2011 2:55 PM
Hi,

I tried to add a custom Header to a client message:

   Dim newMessage As Message = buffer.CreateMessage()
   newMessage.Headers.RemoveAt(0)
   Dim memStream As New MemoryStream()
   Dim xdw As XmlDictionaryWriter = XmlDictionaryWriter.CreateBinaryWriter(memStream)
   xdw.WriteStartElement("wsse", "Security",
http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd)
   xdw.WriteStartElement("wsc", "SecurityContextToken",
http://schemas.xmlsoap.org/ws/2005/02/sc)
   xdw.WriteStartElement("wsc", "Identifier",
http://schemas.xmlsoap.org/ws/2005/02/sc)
   xdw.WriteString("Mytext Entry")
   xdw.WriteEndElement()
   xdw.WriteEndElement()
   xdw.WriteEndElement()
   xdw.Flush()
   Dim MyHeader As MessageHeader
   MyHeader.WriteHeader(xdw, request.Version)
   newMessage.Headers.Add(MyHeader)
   request = newMessage


I got the Methode from a Microsoft  page:

http://msdn.microsoft.com/en-us/library/ms195423(v=VS.90).aspx

But it is not working, it throws an exception: Object reference not set to an instance of an object.

I do not know why. Is there anybody who knows whats wrong?

Lothar


Answers (7)