BizTalk Utilities CV ,   Jobs ,   Code library
 
Go to the front page to continue learning about XML or select below:

Contents

ReBlogger Contents

Previous posts in WSCF/WCF

 
 
Page 2791 of 19351

Accessing the message inside of your WCF service operations

Blogger : BizTalk Blogs
All posts : All posts by BizTalk Blogs
Category : WSCF/WCF
Blogged date : 2008 Jun 05


I have been asked this question many times and thought I just put a quick note here.
If you want to access the message from a WCF service operations then you need to distinguish two cases.

Strongly-typed contracts

public string Hello(string hello)
{
  Console.WriteLine(OperationContext.Current.RequestContext.RequestMessage.ToString());
           
  return hello;
}

Universal contracts

public void Process(Message message)
{
  Console.WriteLine(message.ToString());
}

But calling ToString() on the message itself will only print <stream>…</stream> if it is a streamed message.
In these cases you may need to do something similar like the following snippet in order to print the body of the streamed message.

XmlTextWriter xtw= new XmlTextWriter(Console.Out);
xtw.Formatting = Formatting.Indented;
message.WriteMessage(xtw);
writer.Close();




Read comments or post a reply to : Accessing the message inside of your WCF service operations
Page 2791 of 19351

Newest posts
 

    Email TopXML