Manipulating of Message Header in Silverlight

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

Almost two years ago I have posted in "Hacking of WCF's OperationContext" about manipulating of header of the message in WCF. The same feature is also provided in Silverlight since RTW 2 BETA2. Here is an example:

     Service proxy = new Service();

     proxy.OnOperationCompleted +=
          new EventHandler<DoWorkCompletedEventArgs>(onCompleted);

     using (OperationContextScope ctx=
     new OperationContextScope(proxy.InnerChannel))
     {

        OperationContext.Current.OutgoingMessageHeaders.Add
        (MessageHeader.CreateHeader("SomeHeader",
         "http://daenet.eu", "..."));

         proxy.OperationkAsync("foo");
     }

Next example shows how to obtain the header value:

void onCompleted(IAsyncResult result)
{
     Service proxy = (Service1)result.AsyncState;

     using (OperationContextScope ocs =
     new OperationContextScope(((Service1Client)proxy).InnerChannel))
     {

          string res = proxy.EndDoWork(result);

          string header=
          OperationContext.Current.IncomingMessageHeaders.GetHeader<string>
          ("
SomeHeader", "http://daenet.eu");
     }
}


 


Posted Feb 19 2009, 11:43 PM by Damir Dobric
Filed under:

Comments

Damir Dobric wrote re: Manipulating of Message Header in Silverlight
on 11-14-2009 13:36

Related content: developers.de/.../980.aspx

Damir Dobric Posts wrote WCF: How to append header to HTTP Request?
on 06-04-2011 0:25

Long time ago I have described how to inject the message header in WCF message by using of Operation

Damir Dobric Posts wrote WCF: How to append header to HTTP Request?
on 06-04-2011 0:27

Long time ago I have described how to inject the message header in WCF message by using of Operation

DamirDobric wrote WCF: How to append header to HTTP Request?
on 06-04-2011 0:36

Long time ago I have described how to inject the message header in WCF message by using of Operation

developers.de is a .Net Community Blog powered by daenet GmbH.