开发者

Getting request IP and headers

I am building a service in Windows Workflow Foundation 4.0 in Visual Studio designer m开发者_Go百科ode.

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


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;
    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜