Search
>> Find
Subscriptions
RSS 2.0
Atom 0.3
Contact
Post Categories
.NET
(rss)
ADO.NET Data Services / Astoria
(rss)
Architecture
(rss)
ASMX v2
(rss)
ASP.NET
(rss)
CeBIT
(rss)
Distributed Applications
(rss)
DSL
(rss)
German Posts
(rss)
Interoperability
(rss)
ISB
(rss)
Oslo
(rss)
PDC
(rss)
REST
(rss)
Service Factory
(rss)
SOA
(rss)
Speaking
(rss)
This & that ...
(rss)
VSTS
(rss)
WCF / Indigo
(rss)
Web services Design
(rss)
Web services implementations
(rss)
Web services in .NET
(rss)
Web Services specs & more
(rss)
WF
(rss)
Workflow
(rss)
Writing
(rss)
WSCF
(rss)
WSCF Features
(rss)
WSE
(rss)
News
Affiliations
INETA European Speakers Bureau Member
Microsoft Regional Director
Microsoft MVP
Archives
June 2008 (3)
May 2008 (2)
March 2008 (1)
February 2008 (1)
January 2008 (2)
December 2007 (11)
November 2007 (1)
October 2007 (8)
August 2007 (2)
July 2007 (2)
May 2007 (4)
April 2007 (1)
March 2007 (1)
February 2007 (1)
January 2007 (3)
November 2006 (4)
October 2006 (2)
September 2006 (3)
August 2006 (1)
July 2006 (10)
June 2006 (3)
May 2006 (6)
April 2006 (5)
March 2006 (3)
February 2006 (5)
January 2006 (8)
December 2005 (5)
November 2005 (3)
October 2005 (6)
September 2005 (3)
August 2005 (13)
July 2005 (13)
June 2005 (20)
May 2005 (7)
April 2005 (6)
March 2005 (8)
February 2005 (19)
January 2005 (10)
December 2004 (18)
November 2004 (16)
October 2004 (8)
September 2004 (9)
August 2004 (17)
July 2004 (18)
June 2004 (10)
May 2004 (22)
April 2004 (14)
March 2004 (16)
February 2004 (17)
January 2004 (22)
December 2003 (8)
November 2003 (21)
October 2003 (33)
September 2003 (5)
August 2003 (16)
July 2003 (17)
June 2003 (12)
May 2003 (15)
April 2003 (17)
March 2003 (18)
February 2003 (26)
Christian Weyer: Smells like service spirit
What's first?
Accessing the message inside of your WCF service operations
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.Flush();
writer.Close();
posted on Thursday, June 05, 2008 9:53 AM
Post a Comment
::
#
New and Notable 246 – SOA and WCF Edition
@ Friday, June 06, 2008 2:31 PM
Along with my series , I have a New and Notable. I have pretty much abandoned N&amp;N in favor of writing
Sam Gentile
#
re: Accessing the message inside of your WCF service operations
@ Saturday, June 28, 2008 10:44 PM
RequestContext.RequestMessage is not going to be present on one-way calls, so it's a partial solution at best. I've encountered this problem myself in the past, and ended up writing a message inspector for caching the messages:
http://blogs.microsoft.co.il/blogs/sasha/archive/2008/06/15/obtaining-an-untyped-wcf-message-from-a-typed-service-operation.aspx
Sasha Goldshtein
#
New and Notable 246 – SOA and WCF Edition
@ Thursday, July 24, 2008 4:18 PM
Along with my series , I have a New and Notable. I have pretty much abandoned N&amp;N in favor of writing
Sam Gentile The World According to MSCOREE
© 2002 - 2006 by thinktecture, Ingo Rammer and Christian Weyer. All rights reserved.