Questions tagged [operationcontext]

41 questions
36
votes
3 answers

What is the WCF equivalent of HttpContext.Current.Request.RawUrl?

I've got some RESTful services running in a pure WCF context (i.e. ASP.NET compatibility is not enabled, and thus there is no HttpContext.Current object available). The URLs to the services are rewritten at the start of the request using an…
Greg Beech
  • 133,383
  • 43
  • 204
  • 250
18
votes
4 answers

How to log the raw request in WCF service

I have a WCF service with several methods. I would like to log the raw request that came in from the client regardless of how this was sent. One method accepts the data as a querystring (strictly for legacy support) which I can log…
Maloric
  • 5,525
  • 3
  • 31
  • 46
10
votes
5 answers

current OperationContext is null in WCF Windows Service

I am trying to set up a Publish/Subscribe system using WCF and where the WCF server is in a Windows service. The binding is net.TCP. The service is providing a "Subscribe" method to the client so the client can register a callback handler to an…
dtaylor
  • 997
  • 3
  • 10
  • 26
8
votes
1 answer

How to retrieve the client's machine name from within a WCF Operation Contract?

I'm currently looking at the OperationContect.Current properties. Is there a (nested) property the will always return the machine name of the client? I'm currently using net.tcp binding, but would like to support additional bindings in the…
chilltemp
  • 8,854
  • 8
  • 41
  • 46
8
votes
4 answers

WCF 4 REST service can't return a StatusDescription, only StatusCode

I'm currently migrating my WCF RESTful service from .NET 3.5 (Starter Kit) to .NET 4. I started my project using a WCF Rest service template from Visual Studio 2010. I had to figure out how to keep my authorization scheme (formely done with…
7
votes
3 answers

OperationContext is null after async method using .net 4.6.2

I have a problem with OperationContext getting null after an async operation is called (and my threadid changes). I know this is a know issue and I've gone threw some StackOverflow questions regarding the issue. In .net 4.6.2 there is a fix for the…
Amir Popovich
  • 29,350
  • 9
  • 53
  • 99
7
votes
1 answer

WCF: Distinguish between REST and SOAP requests using the OperationContext

In WCF security, given the current OperationContext, what is the best way to determine whether the request is a SOAP request or a REST request?
urig
  • 16,016
  • 26
  • 115
  • 184
6
votes
1 answer

Propagate OperationContext into Async WCF Call

With C#5 Async-Await in WCF, after an await if rest of the code continues on a different thread, we loose the Current Operation Context. (OperationContext.Current is null). I am working on a WCF Service which calls another external service. And…
user3152534
  • 61
  • 1
  • 4
5
votes
1 answer

How to read WCF message headers in duplex callback?

In a normal WCF request/reply contract, you can read the message headers using something like: OperationContract.Current.IncomingMessageHeaders What I can't figure out is how to do this on the callback side of a duplex contract. Inside the callback…
Simon Gillbee
  • 3,932
  • 4
  • 35
  • 48
4
votes
3 answers

Making WCF OperationContext play nicely with DI and testing

I'm running a WCF service hosted in a Windows service; dependencies of the WCF service are injected via Unity, which is all good. As a result, the service is also easy to write unit tests for. Recently, I added functionality to the service that…
4
votes
3 answers

Keep OperationContext in task parallel library

we have somewhere in a deep abstraction assembly a WCF behavior that reads data from the OperationContext.Current, when this code is executed from within a Task, the OperationContext.Current is empty, is it possible to solve this inside the…
Tim Mahy
  • 1,319
  • 12
  • 28
3
votes
1 answer

How can I get the exception object inside a IDispatchMessageInspector?

My WCF application uses an IDispatchMessageInspector for some advanced monitoring - when an error occurs and when no error occurs. I'm looking for a way to get the exception that occurred in my service when I get to the…
Amir Popovich
  • 29,350
  • 9
  • 53
  • 99
3
votes
1 answer

Allowing operations to access shared context (such as OperationContext in WCF)

I would like to implement a certain context for ongoing operations in my application (.NET, C#) such that code that is started an executed by the application could access it. The issue is that the context is not being passed around as an object,…
lysergic-acid
  • 19,570
  • 21
  • 109
  • 218
3
votes
1 answer

Storing OperationContext.Current in a instance variable of a WCF service instance

I wanted to know if it is wise to store and reference the OperationContext.Current object in a instance variable of a WCF service host instance. The service host is set to InstanceContextMode.PerCall so every new request gets its own instance. The…
Mohammed Ali
  • 1,027
  • 1
  • 9
  • 16
2
votes
3 answers

Read request content in JSON form from OperationContext in C#

I have created WCF RESTful service as below: [OperationContract] [WebInvoke(Method = "PUT", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, UriTemplate = "/Customer/{customerID}/profile")] string…
I Love Stackoverflow
  • 6,738
  • 20
  • 97
  • 216
1
2 3