views:

183

answers:

2

I am building a service in Windows Workflow Foundation 4.0 in Visual Studio designer mode.

How do I retrieve client IP and request headers in WF, VS Designer mode?

A: 

The way to get the WCF details from the incoming request is to implement the IReceiveMessageCallback and add that class to the NativeActivityContext.Properties. In the OnReceiveMessage() function you will receive the WCF OperationContext allowing you to retreive any data you like from there.

Maurice
This is a question about WF not WCF
Ruby
So what kind of IP address and request headers are you revering to?
Maurice
@Maurice: what kind of IP address?? Well one that looks like this: 70.23.34.32
Ruby
@Ruby: If you're not using the WCF activities, what activities are you using to receive the client request?
Richard
@Richard: I am using Windoes Workflow 4 and Workflow activities in the VS designer mode like Assign, InvokeMethod, If, GetRequest, SendRequest, etc. You can drag-n-drop these activities from the toolbox in VS once you create a "WCF Workflow Service Application"
Ruby
So you *are* using WCF despite your initial comment to this A, and the A has what you need.
Richard
+1  A: 

Seems like what you want to do is put an InvokeMethod activity (this is in the Primitives section of the Toolbox) in your workflow in the designer. There you specify a class type and the method to be called. Inside this method you can call the OperationContext class to get the client address and the request headers like so:

public class Class1 {
    public static void SomeMethod() {
        EndpointAddress clientAddress = OperationContext.Current.Channel.RemoteAddress;
        MessageHeaders headers = OperationContext.Current.RequestContext.RequestMessage.Headers;
        // Do something with the address and / or headers...
        return;
    }
}
Steve Ellinger