2

I am consuming one java webservice with WCF client. I want to pass user related information to service in header. I have aleady gone to through thread How to add a custom header to every WCF calls?

I have implemented IClientMessageInspector interface with BeforeSendRequest() method. Now, I want to pass user related information in SOAP header like Oraganization, which may differ for every user. I have all this information in my ASP.net application, which uses this service.

Is there anyway I can pass user related information to this BeforeSendRequest() method from asp.net session and build Message header before sending any request?

Community
  • 1
  • 1
Tanaji Kamble
  • 353
  • 1
  • 3
  • 17

1 Answers1

1

There are few options

  1. Put the information in Session and retrieve it in BeforeSendRequest
  2. Put it in HttpContext.Current.Items and retrieve it in `BeforeSendRequest'
  3. Use Thread Local Storage (http://msdn.microsoft.com/en-us/library/6sby1byh.aspx)
Suhas
  • 7,919
  • 5
  • 34
  • 54
  • 1
    Thread local storage is anti pattern in ASP.NET because threads are reused for many requests. – Ladislav Mrnka Mar 07 '11 at 10:15
  • @Ladislav: I did not know this. Thanks for the information. Even then, a request would be only on one thread, right? So in this particular example, I can still use TLS. Isn't it? – Suhas Mar 08 '11 at 05:37