Communicating between Silverlight and wcf service using MessageHeaders

Posted by Elizas under ASP.NET on 2/24/2010 | Views : 2361 | Status : [Member] | Replies : 2
We can use messageHeaders to check and authenticate the connection between the Silverlight and WCF service. Operation context of type System.ServiceModel holds the information for the current operation in client and service side.

For sending messages from the client side we will use the OutgoingMessageHeaders of type System.ServiceModel.Channels.MessageHeaders and similarly for receiving header information in service side we will use IncomingMessageHeaders.

Suppose we want to send the username and password from the client and check in the service side we can use messageHeaders.

Here in the client side we can create header with the CreateHeader function with the parameter CreateHeader(name as string,ns as string,value as object)

Imports System.ServiceModel.Channels

Dim PersonObj As New Person
PersonObj.UserName = "Soumyap"
PersonObj.Password = "Mindfire"

Dim messageHeadersElementOutgoing As MessageHeaders = OperationContext.Current.OutgoingMessageHeaders
messageHeadersElementOutgoing.Add(MessageHeader.CreateHeader("Authentication", "", PersonObj))



Posted by: Vuyiswamb on: 2/24/2010 [Member] [MVP] [Administrator] NotApplicable

Good Day Eliza

We appreciate your effort to share your Knowledge. I suggest you write an Article about this. in the Forum Section we only post questions only. i will dellete this post. i will give you 15 minutes to copy this content to where it belongs.

Thank you for Posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda

Elizas, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/24/2010 [Member] Bronze

Yes, The information was useful..

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Elizas, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response