developers.de
daenet's .NET Community

Manipulating of Message Header in Silverlight

Damir Dobric Posts

 

Damir@Phone    



My upcoming sessions:

AppFabric Applications at
NRW Conf 2011
09.Sept.2011 Wuppertal

HTML5 widgets in WP7+
Monodroid
Mobility Day
21.Sept.2011 - Zagreb

AppFabric and WCF sessions at
Advanced Developer Conference
26.-27. Oktober 2011 in Frankenthal

AppFabric Applications, queues, topics and more at
Prio Conference
02. - 03. November 2011 in Meistersingerhalle Nürnberg

AppFabric Applications deep dive hosted by
.NET User Group Frankfurt
17.Nov.2011 18.30-22.30 Microsoft - Bad Homburg 

 

 

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

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
daenet GmbH