operationcontext

current OperationContext is null in WCF Windows Service

早过忘川 提交于 2020-01-10 04:54:59
问题 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 event that will be raised from a DLL linked to the server. In the Subscribe method I attempt to get the callback channel using the OperationContext.Current.GetCallbackChannel method. When I attempt this the OperationContext.Current property returns

WCF: Distinguish between REST and SOAP requests using the OperationContext

一世执手 提交于 2019-12-20 23:27:12
问题 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? 回答1: You could look at the binding name on the ChannelDispatcher: string bindingName = OperationContext.Current .EndpointDispatcher.ChannelDispatcher.BindingName; For REST, it would be webHttpBinding - anything else would be SOAP. 来源: https://stackoverflow.com/questions/3179863/wcf-distinguish-between-rest-and-soap-requests-using-the-operationcontext

OperationContext.Current and HttpContext.Current are null in OWIN hosted Web API 2

谁说我不能喝 提交于 2019-12-12 03:57:06
问题 I am moving some of WCF services to the Web API. OperationContext.Current is usually used in WCF for logging and staging purposes. But i'm seeing HttpContext.Current and OperationContext.Current as null. I have used a framework which uses OperationContext.Current to get the execution context for the current thread. So if i am opting for other ways, i have to add my custom method to the framework, which i am trying to avoid. Questions: What is the workaround that i can adopt? If "adding to

Can´t add header to MassTransit message from OperationContext?

∥☆過路亽.° 提交于 2019-12-08 10:00:32
问题 I am trying to add a header to a Masstransit message containing information from the currently logged user on a WCF Web application. So at my web app, I have the following when the app starts: IBusControl bus = Bus.Factory.CreateUsingRabbitMq(cfg => { cfg.Host(new Uri("rabbitmq://localhost/test"), r => { //... }); cfg.ConfigureSend( s => s.UseSendExecute( c => c.Headers.Set(Constants.UserInfo, OperationContext.Current.Channel.Extensions.Find<PropertyUserInfo>().Info))); }); I am using an IoC

Propagate OperationContext into Async WCF Call

偶尔善良 提交于 2019-12-06 02:05:18
问题 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 there are a few Custom Binding Extensions used in the external service call which access the Operation Context. So I need the Context to be propagated during this call and it cant just work with copying the operation context into a local variable. My

WCF: Distinguish between REST and SOAP requests using the OperationContext

天涯浪子 提交于 2019-12-03 08:09:23
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? You could look at the binding name on the ChannelDispatcher: string bindingName = OperationContext.Current .EndpointDispatcher.ChannelDispatcher.BindingName; For REST, it would be webHttpBinding - anything else would be SOAP. 来源: https://stackoverflow.com/questions/3179863/wcf-distinguish-between-rest-and-soap-requests-using-the-operationcontext

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

笑着哭i 提交于 2019-11-29 19:35:23
问题 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 future. Using .NET 3.5 SP1 回答1: You can get the remote endpoint's IP address from the current OperationContext's IncomingMessageProperties, eg: RemoteEndpointMessageProperty messageProperty = OperationContext.Current.IncomingMessageProperties

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

安稳与你 提交于 2019-11-27 11:31:59
问题 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 IHttpModule (which at that point does have an HttpContext and rewrites it using HttpContext.Current.RewritePath ) to get rid of things like the .svc extension from the URL. However, I need to access the original URL that was requested from within the WCF