tags:

views:

35

answers:

1

Hi, as in the title, i have:

[ServiceContract]
    public interface IService
    {
        [OperationContract]
        [WebGet(UriTemplate="abc")]
        Stream GetResponse(Stream in);
    }

    public class Service : IService
    {
        public Stream GetResponse(Stream in)
        {
           some_function()
        }   
    }

is it possible to pass a request context to some other function that will respond to the request?

+1  A: 

Yes, within some_function you can access the current WCF OperationContext via the static Current property which will give you full access to everything about the request. Or, better yet, you can design some_function to accept an OperationContext parameter and then it doesn't have to pull it out of thin air itself which actually makes for better testability.

In addition to the context, you will also need to take and return the Stream instances from some_function if it intends to act on them.

So your some_function might look something like this:

public Stream GetResponse(Stream in) 
{ 
    return some_function(OperationaContext.Current, in);
} 
Drew Marsh