wcf-behaviour

Get SignalR User (Hub.Context) outside of hub

本小妞迷上赌 提交于 2019-12-12 13:45:27
问题 is there any way to get current signalR request user outside the hub? I can use Hub.Context.User inside of hub methods, but if hub method calls any other underlying layer? Wcf service call - an additional BehaviorExtensionElement is used to add wcf message header with current user identity name. public object BeforeSendRequest(ref Message request, IClientChannel channel) { request.Headers.Add(MessageHeader.CreateHeader( Constants.HeaderNames.SessionId, Constants.HeaderNames.HeaderNamespace,

WCF endpointBehaviors extension not picked up when the name param is present?

旧时模样 提交于 2019-12-07 09:38:12
问题 I am trying to extend my service endpoint behaviour with custom MessageInspector, extension works fine and its picked up, but only if I don’t define the “name” parameter on behaviour tag and don’t define specific behaviorConfiguration on the endpoint. This means I am extending all endpoints and this is what I don’t want. Could anyone please explain me what am I doing wrong? This config doesn't pick up myBehaviour extension and doesn't fail. <system.serviceModel> <services> <service name=

Something like an operation filter in WCF REST?

北城以北 提交于 2019-12-06 09:28:53
问题 I am looking for something like the AuthorizeAttribute in MVC, something I can use like this: [WebGet(UriTemplate = "data/{spageNumber}")] [WebCache(CacheProfileName = "SampleProfile")] [WcfAuthorize] public IEnumerable<SampleItem> GetCollection(String spageNumber) { Int32 itemsPerPage = 10; Int32 pageNumber = Int32.Parse(spageNumber); return Enumerable.Range(pageNumber * itemsPerPage, itemsPerPage) .Select(i => SampleItem.Create(i)); } That WcfAuthorizeAttribute , will try to authenticate

WCF endpointBehaviors extension not picked up when the name param is present?

蹲街弑〆低调 提交于 2019-12-05 17:13:12
I am trying to extend my service endpoint behaviour with custom MessageInspector, extension works fine and its picked up, but only if I don’t define the “name” parameter on behaviour tag and don’t define specific behaviorConfiguration on the endpoint. This means I am extending all endpoints and this is what I don’t want. Could anyone please explain me what am I doing wrong? This config doesn't pick up myBehaviour extension and doesn't fail. <system.serviceModel> <services> <service name="testService"> <endpoint address="http://localhost:9999/TestServiceService" binding="wsHttpBinding" contract

Something like an operation filter in WCF REST?

故事扮演 提交于 2019-12-04 16:45:46
I am looking for something like the AuthorizeAttribute in MVC, something I can use like this: [WebGet(UriTemplate = "data/{spageNumber}")] [WebCache(CacheProfileName = "SampleProfile")] [WcfAuthorize] public IEnumerable<SampleItem> GetCollection(String spageNumber) { Int32 itemsPerPage = 10; Int32 pageNumber = Int32.Parse(spageNumber); return Enumerable.Range(pageNumber * itemsPerPage, itemsPerPage) .Select(i => SampleItem.Create(i)); } That WcfAuthorizeAttribute , will try to authenticate the user with FormsAuthentication, and set the context's IPrincipal, or return a HTTP 401 Unauthorized. I

Unit Testing a WCF Behavior Extension

流过昼夜 提交于 2019-11-30 22:40:43
This is driving me crazy. I have an extension which we use to alter the Content Response of a request if there is an error. Basically, if everything works it gets serialized to JSON as normal, but if we get an unhandled exception, we serialize based on a different object. We need unit tests around this but I cannot figure out how to write them. The means to validate that it worked revolves around the StatusCode, the fault Message instance, and the ContentType of the response. To modify the Response going back, I utilize the WebOperationContext static class. I have seen examples of mocking this

Unit Testing a WCF Behavior Extension

ε祈祈猫儿з 提交于 2019-11-30 17:48:12
问题 This is driving me crazy. I have an extension which we use to alter the Content Response of a request if there is an error. Basically, if everything works it gets serialized to JSON as normal, but if we get an unhandled exception, we serialize based on a different object. We need unit tests around this but I cannot figure out how to write them. The means to validate that it worked revolves around the StatusCode, the fault Message instance, and the ContentType of the response. To modify the

Custom Behavior won't register in my web.config

吃可爱长大的小学妹 提交于 2019-11-30 06:43:07
问题 I have a working application using Json.NET (newtonsoft) as a custom serializer. Currently I'm adding this derivative of WebHttpBehavior in a custom WebServiceHostFactory. See the code snippet at the end of this blog for how I've attached it. As I'm hosting this service in IIS, I would like to get rid of my custom hosting code and simply add the custom behavior to my web.config. The procedure is shown in this msdn article. So I try to do that like so: <behaviors> <endpointBehaviors> <behavior