public object AfterReceiveRequest(ref Message request,
               IClientChannel channel,
               InstanceContext instanceContext)
        {
            // Extract Cookie (name=value) from messageproperty
            var messageProperty = (HttpRequestMessageProperty)
                OperationContext.Current.IncomingMessageProperties[HttpRequestMessageProperty.Name];
            string cookie = messageProperty.Headers.Get("Set-Cookie");
            if (string.IsNullOrWhiteSpace(cookie))
                return null;

            string[] nameValue = cookie.Split('=', ',');
            string userName = string.Empty;

            // Set User Name from cookie
            int pos = nameValue.ToList().IndexOf(".ASPXAUTH");
            if (pos == -1)
                return null;

            userName = nameValue[pos + 1];

            // Set Thread Principal to User Name
            EnterpriseIdentity enterpriseIdentity = new EnterpriseIdentity();
            GenericPrincipal threadCurrentPrincipal =
                   new GenericPrincipal(enterpriseIdentity, new string[] { });
            enterpriseIdentity.IsAuthenticated = true;
            enterpriseIdentity.Name = userName;
            System.Threading.Thread.CurrentPrincipal = threadCurrentPrincipal;

            return null;
        }
Example #2
0
 public object AfterReceiveRequest(ref Message request,
     IClientChannel channel,
     InstanceContext instanceContext)
 {
     request = TraceHttpRequestMessage(request.ToHttpRequestMessage());
     return null;
 }
Example #3
0
 static void Main(string[] args)
 {
     InstanceContext site = new InstanceContext(new CallbackHandler());
     DuplexSvcClient proxy = new DuplexSvcClient(site);
     proxy.ReturnTime(2, 5);
     Console.ReadKey();
 }
Example #4
0
        static void Main(string[] args)
        {
            InstanceContext site = new InstanceContext(null, new Client());
            SampleContractClient client = new SampleContractClient(site);

            //create a unique callback address so multiple clients can run on one machine
            WSDualHttpBinding binding = (WSDualHttpBinding)client.Endpoint.Binding;
            string clientcallbackaddress = binding.ClientBaseAddress.AbsoluteUri;
            clientcallbackaddress += Guid.NewGuid().ToString();
            binding.ClientBaseAddress = new Uri(clientcallbackaddress);

            //Subscribe.
            Console.WriteLine("Subscribing");
            client.Subscribe();

            Console.WriteLine();
            Console.WriteLine("Press ENTER to unsubscribe and shut down client");
            Console.ReadLine();

            Console.WriteLine("Unsubscribing");
            client.Unsubscribe();

            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();

        }
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            bool shouldCompressResponse = false;

            object propObj;
            if (request.Properties.TryGetValue(HttpRequestMessageProperty.Name, out propObj))
            {
                var prop = (HttpRequestMessageProperty)propObj;
                var accept = prop.Headers[HttpRequestHeader.Accept];
                if (accept != null)
                {
                    if (jsonContentTypes.IsMatch(accept))
                    {
                        WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Json;
                    }
                    else if (xmlContentTypes.IsMatch(accept))
                    {
                        WebOperationContext.Current.OutgoingResponse.Format = WebMessageFormat.Xml;
                    }
                }

                var acceptEncoding = prop.Headers[HttpRequestHeader.AcceptEncoding];
                if (acceptEncoding != null && acceptEncoding.Contains("gzip"))
                {
                    shouldCompressResponse = true;
                }
            }

            return shouldCompressResponse;
        }
 public static Object GetWcfReference(Type type, object[] info)
 {
   if (info.Length == 2)
     info = new object[] { info[0], null, info[1] };
   if (info.Length != 3)
     return null;
   Type genType;
   Type factType;
   if (info[0] == null)
   {
     genType = typeof(ChannelFactory<>);
     factType = genType.MakeGenericType(new Type[] { type });
     if (info[1] == null)
       info[1] = new WSHttpBinding();
     info = new object[] { info[1], new EndpointAddress((string)info[2]) };
   }
   else
   {
     genType = typeof(DuplexChannelFactory<>);
     factType = genType.MakeGenericType(new Type[] { type });
     info[0] = new InstanceContext(info[0]);
     info[2] = new EndpointAddress((string)info[2]);
     if (info[1] == null)
       info[1] = new WSDualHttpBinding();
   }
   object factObject = Activator.CreateInstance(factType, info);
   MethodInfo methodInfo = factType.GetMethod("CreateChannel", new Type[] { });
   return methodInfo.Invoke(factObject, null);
 }
Example #7
0
 public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
 {
     var reply = request.Headers.ReplyTo;
     OperationContext.Current.OutgoingMessageHeaders.To = reply.Uri;
     OperationContext.Current.OutgoingMessageHeaders.RelatesTo = request.Headers.MessageId;
     return null;
 }
 public object GetInstance(InstanceContext instanceContext)
 {
     if (_container == null)
         _container = WCF_IOC.Infra.CrossCutting.IoC.IoC.Initialize();
     return _container.GetInstance(_serviceType);
     //ObjectFactory.GetInstance(_serviceType);
 }
Example #9
0
        static void Main(string[] args)
        {
            NameCallBackHandler nameHandler = new NameCallBackHandler();
            InstanceContext instanceContextName = new InstanceContext(nameHandler);

            DualNameServiceClient nameClient = new DualNameServiceClient(instanceContextName);
            Console.WriteLine("Displaying name ");

            nameClient.ShowName();

            WaitHandle.WaitAll(new AutoResetEvent[]{nameHandler.ResetEvent});

            Console.WriteLine("Exiting main....");
            
            //InstanceContext instanceContext = new InstanceContext(new CallbackHandler());
            //DualCalculatorServiceClient client = new DualCalculatorServiceClient(instanceContext);
            //Console.WriteLine("Press <ENTER> to terminate client once the output is displayed.");
            //Console.WriteLine();

            //double value = 100.00D;
            
            //client.AddTo(value);

            //value = 50.00D;
            //client.SubtractFrom(value);

            //client.Clear();
            //Console.ReadLine();
            //client.Close();

        }
        /// <summary>
        ///     Called when an inbound message been received
        /// </summary>
        /// <param name="request">The request message.</param>
        /// <param name="channel">The incoming channel.</param>
        /// <param name="instanceContext">The current service instance.</param>
        /// <returns>
        ///     The object used to correlate stateMsg.
        ///     This object is passed back in the method.
        /// </returns>
        public object AfterReceiveRequest(ref Message request,
            IClientChannel channel,
            InstanceContext instanceContext)
        {
            StateMessage stateMsg = null;
            HttpRequestMessageProperty requestProperty = null;
            if (request.Properties.ContainsKey(HttpRequestMessageProperty.Name))
            {
                requestProperty = request.Properties[HttpRequestMessageProperty.Name]
                    as HttpRequestMessageProperty;
            }

            if (requestProperty != null)
            {
                var origin = requestProperty.Headers["Origin"];
                if (!string.IsNullOrEmpty(origin))
                {
                    stateMsg = new StateMessage();
                    // if a cors options request (preflight) is detected, 
                    // we create our own reply message and don't invoke any 
                    // operation at all.
                    if (requestProperty.Method == "OPTIONS")
                    {
                        stateMsg.Message = Message.CreateMessage(request.Version, null);
                    }
                    request.Properties.Add("CrossOriginResourceSharingState", stateMsg);
                }
            }

            return stateMsg;
        }
Example #11
0
        static void Main()
        {
            // Construct InstanceContext to handle messages on callback interface
            InstanceContext instanceContext = new InstanceContext(new CallbackHandler());

            // Create a client with given client endpoint configuration
            CalculatorDuplexClient client = new CalculatorDuplexClient(instanceContext);

            Console.WriteLine("Press <ENTER> to terminate client once the output is displayed.");
            Console.WriteLine();

            // Call the AddTo service operation.
            double value = 100.00D;
            client.AddTo(value);

            // Call the SubtractFrom service operation.
            value = 50.00D;
            client.SubtractFrom(value);

            // Call the MultiplyBy service operation.
            value = 17.65D;
            client.MultiplyBy(value);

            // Call the DivideBy service operation.
            value = 2.00D;
            client.DivideBy(value);

            // Complete equation
            client.Clear();

            Console.ReadLine();

            //Closing the client gracefully closes the connection and cleans up resources
            client.Close();
        }
        public ServiceAgent(string Url)
        {
            try
            {
                 InstanceContext context = new InstanceContext(this);
                 NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
                 binding.MaxReceivedMessageSize = 2147483647;
                 binding.ReaderQuotas.MaxDepth= 2147483647;
                 binding.ReaderQuotas.MaxStringContentLength=2147483647;
                 binding.ReaderQuotas.MaxArrayLength= 2147483647;
                 binding.ReaderQuotas.MaxBytesPerRead= 2147483647;
                 binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
                 binding.OpenTimeout = TimeSpan.FromMinutes(10);
                 binding.SendTimeout = TimeSpan.FromMinutes(20);
                 binding.ReceiveTimeout = TimeSpan.FromMinutes(20);
                 binding.MaxBufferPoolSize = 2147483647;

                _proxy = new KryptonServiceProxy(context, binding, Url);
                _proxy.Open();
            }
               catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _proxy = null;
            }
        }
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            CorsState state = null;
            HttpRequestMessageProperty responseProperty = null;
            if (request.Properties.ContainsKey(HttpRequestMessageProperty.Name))
            {
                responseProperty = request.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
            }

            if (responseProperty != null)
            {

                //Handle cors requests
                var origin = responseProperty.Headers["Origin"];
                if (!string.IsNullOrEmpty(origin))
                {
                    state = new CorsState();
                    //if a cors options request (preflight) is detected, we create our own reply message and don't invoke any operation at all.
                    if (responseProperty.Method == "OPTIONS")
                    {
                        state.Message = Message.CreateMessage(request.Version, FindReplyAction(request.Headers.Action), new EmptyBodyWriter());
                    }
                    request.Properties.Add(CrossOriginResourceSharingPropertyName, state);
                }
            }
            return state;
        }
        private void InitializeProxy(string IpAddress, CallBackFunctionSignature callback)
        {
            try
            {
                 Url = string.Format("net.tcp://{0}:8001/KryptonService", IpAddress);
                 _callback = callback;

                 InstanceContext context = new InstanceContext(this);
                 NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);
                 binding.MaxReceivedMessageSize = 2147483647;
                 binding.ReaderQuotas.MaxDepth= 2147483647;
                 binding.ReaderQuotas.MaxStringContentLength=2147483647;
                 binding.ReaderQuotas.MaxArrayLength= 2147483647;
                 binding.ReaderQuotas.MaxBytesPerRead= 2147483647;
                 binding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
                 binding.OpenTimeout = TimeSpan.FromMinutes(10);
                 binding.SendTimeout = TimeSpan.FromMinutes(20);
                 binding.ReceiveTimeout = TimeSpan.FromMinutes(20);
                 binding.MaxBufferPoolSize = 2147483647;

                _proxy = new KryptonServiceProxy(context, binding, Url);
                _proxy.Open();
            }
               catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                _proxy = null;
            }
        }
 public void ReleaseInstance(InstanceContext instanceContext, object instance)
 {
     if (instance is IDisposable)
     {
         (instance as IDisposable).Dispose();
     }
 }
Example #16
0
 // 异步的Join操作,首先调用BeginJoin,该操作完成后将调用OnEndJoin。
 public void Connect(Person p)
 {
     InstanceContext site = new InstanceContext(this);
     proxy = new ChatClient(site);
     IAsyncResult iar =
     proxy.BeginJoin(p, new AsyncCallback(OnEndJoin), null);
 }
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            if (request.Properties.ContainsKey("UriTemplateMatchResults"))
            {
                HttpRequestMessageProperty httpmsg = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];
                UriTemplateMatch match = (UriTemplateMatch)request.Properties["UriTemplateMatchResults"];

                string format = match.QueryParameters["$format"];
                if ("json".Equals(format, StringComparison.InvariantCultureIgnoreCase))
                {
                    // strip out $format from the query options to avoid an error
                    // due to use of a reserved option (starts with "$")
                    match.QueryParameters.Remove("$format");

                    // replace the Accept header so that the Data Services runtime 
                    // assumes the client asked for a JSON representation
                    httpmsg.Headers["Accept"] = "application/json, text/plain;q=0.5";
                    httpmsg.Headers["Accept-Charset"] = "utf-8";

                    string callback = match.QueryParameters["$callback"];
                    if (!string.IsNullOrEmpty(callback))
                    {
                        match.QueryParameters.Remove("$callback");
                        return callback;
                    }
                }
            }

            return null;
        }
Example #18
0
 public object BeforeInvoke(InstanceContext instanceContext,
     IClientChannel channel,
     Message message)
 {
     UnitOfWork = Rhino.Commons.UnitOfWork.Start();
     return null;
 }
Example #19
0
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            if (!request.IsFault && !request.IsEmpty)
                LogRequest(ref request);

            return null;
        }
 void AddItem(InstanceContext instanceContext)
 {
     int index = this.firstFreeIndex;
     this.firstFreeIndex = this.items[index].nextFreeIndex;
     this.items[index].instanceContext = instanceContext;
     instanceContext.InstanceContextManagerIndex = index;
 }
        public object AfterReceiveRequest(ref Message request, IClientChannel channel, InstanceContext instanceContext)
        {
            var httpRequest = request.Properties[HttpRequestMessageProperty.Name] as HttpRequestMessageProperty;
            var authorizationHeader = httpRequest.Headers["Authorization"];

            if (string.IsNullOrEmpty(authorizationHeader))
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }

            string user;
            string password;

            this.ParseUserPasswordFromHeader(authorizationHeader, out user, out password);

            if (string.IsNullOrEmpty(user) || string.IsNullOrEmpty(password))
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }

            var authenticationService = ObjectFactory.GetInstance<IAuthenticationService>();

            if (!authenticationService.Authenticate(user, password))
            {
                throw new HttpResponseException(HttpStatusCode.Unauthorized);
            }

            return instanceContext;
        }
Example #22
0
		internal void CreateSession()
		{
			Uri serviceAddress = new Uri("net.pipe://localhost/Multitouch.Service/ApplicationInterface");
			EndpointAddress remoteAddress = new EndpointAddress(serviceAddress);
			NetNamedPipeBinding namedPipeBinding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
			namedPipeBinding.MaxReceivedMessageSize = int.MaxValue;
			namedPipeBinding.MaxBufferSize = int.MaxValue;
			namedPipeBinding.ReaderQuotas.MaxArrayLength = int.MaxValue;
			namedPipeBinding.ReceiveTimeout = TimeSpan.MaxValue;

			IApplicationInterfaceCallback dispatcher = new MultitouchServiceContactDispatcher(logic);
			InstanceContext instanceContext = new InstanceContext(dispatcher);
			service = new ApplicationInterfaceClient(instanceContext, namedPipeBinding, remoteAddress);

			try
			{
				service.CreateSession();
				MouseHelper.SingleMouseFallback = false;
			}
			catch (EndpointNotFoundException)
			{
				//throw new MultitouchException("Could not connect to Multitouch service, please start Multitouch input server before running this application.", e);
				Trace.TraceWarning("Could not connect to Multitouch service. Enabling single mouse input.");
				SingleMouseClientAndDispatcher client = new SingleMouseClientAndDispatcher(logic);
				service = client;
				dispatcher = client;
				MouseHelper.SingleMouseFallback = true;
			}
			contactDispatcher = dispatcher;
		}
        public object AfterReceiveRequest(ref Message request,
		                                  IClientChannel channel,
		                                  InstanceContext instanceContext)
        {
            OperationContext.Current.Extensions.Add(new WorkerContext());
            return request.Headers.MessageId;
        }
Example #24
0
        public bool Connect(ClientCrawlerInfo clientCrawlerInfo)
        {
            try
            {
                var site = new InstanceContext(this);

                var binding = new NetTcpBinding(SecurityMode.None);
                //var address = new EndpointAddress("net.tcp://localhost:22222/chatservice/");

                var address = new EndpointAddress("net.tcp://193.124.113.235:22222/chatservice/");
                var factory = new DuplexChannelFactory<IRemoteCrawler>(site, binding, address);

                proxy = factory.CreateChannel();
                ((IContextChannel)proxy).OperationTimeout = new TimeSpan(1, 0, 10);

                clientCrawlerInfo.ClientIdentifier = _singletoneId;
                proxy.Join(clientCrawlerInfo);

                return true;
            }

            catch (Exception ex)
            {
                MessageBox.Show("Error happened" + ex.Message);
                return false;
            }
        }
Example #25
0
        //其他成员
        private void MonitorForm_Load(object sender, EventArgs e)
        {
            string header = string.Format("{0, -13}{1, -22}{2}", "Client", "Time", "Event");
            this.listBoxExecutionProgress.Items.Add(header);
            _syncContext = SynchronizationContext.Current;
            _callbackInstance = new InstanceContext(new CalculatorCallbackService());
            _channelFactory = new DuplexChannelFactory<ICalculator>(_callbackInstance, "calculatorservice");

            EventMonitor.MonitoringNotificationSended += ReceiveMonitoringNotification;
            this.Disposed += delegate
            {
            EventMonitor.MonitoringNotificationSended -= ReceiveMonitoringNotification;
            _channelFactory.Close();
            };

            for (int i = 0; i < 2; i++)
            {
            ThreadPool.QueueUserWorkItem(state =>
            {
                int clientId = Interlocked.Increment(ref _clientId);
                EventMonitor.Send(clientId, EventType.StartCall);
                ICalculator proxy = _channelFactory.CreateChannel();
                using (OperationContextScope contextScope = new OperationContextScope(proxy as IContextChannel))
                {
                    MessageHeader<int> messageHeader = new MessageHeader<int>(clientId);
                    OperationContext.Current.OutgoingMessageHeaders.Add(messageHeader.GetUntypedHeader(EventMonitor.CientIdHeaderLocalName, EventMonitor.CientIdHeaderNamespace));
                    proxy.Add(1, 2);
                }
                EventMonitor.Send(clientId, EventType.EndCall);
            }, null);
            }
        }
        public static void ConnectIpc(IServiceRemotingCallback serviceRemotingCallback)
        {
            InstanceContext instanceContext = new InstanceContext(serviceRemotingCallback);

            PipeFactory = new DuplexChannelFactory<IServiceRemoting>(instanceContext, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/BitCollectors.PlinkService/PlinkService"));
            RemotingObject = PipeFactory.CreateChannel();
        }
        static SupplierServiceInvoker()
        {
            CallbackContext = new SupplierCallback();
            InstanceContext context = new InstanceContext(CallbackContext);

            client = new CentralSupplierServiceClient(context);
        }
Example #28
0
 public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel, InstanceContext instanceContext)
 {
     /* Add request Logging code here
      *  Message contents in request.ToString()
      */
     return null;
 }
Example #29
0
        static void Main(string[] args)
        {
            Console.WriteLine("create service...");
            var instanceContext = new InstanceContext(new callback());
            var service = new ServiceReference1.SimulationInformationServiceClient(instanceContext);
            service.Open();

            Console.WriteLine("ping server boolean");
            var result = service.PingServerBoolean();
            Console.WriteLine("done: "+result);

            Console.WriteLine("ping server void");
            service.PingServerVoid();
            Console.WriteLine("done");

            //Console.WriteLine("ping server void and ping back");
            //result = service.PingServerBooleanAndPingBack();
            //Console.WriteLine("done: "+result);

            Console.WriteLine("subscribe to sensor data");
            result = service.SubscribeSensorData();
            Console.WriteLine("done: " + result);

            Console.ReadLine();
        }
 public object GetInstance(InstanceContext instanceContext, Message message)
 {
     //if (_container == null)
     //    CreateBehavior();
     return _container.GetInstance(_serviceType);
     //return ObjectFactory.GetInstance(_serviceType);
 }
Example #31
0
 public GameServiceClient(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
     base(callbackInstance, binding, remoteAddress)
 {
 }
Example #32
0
 public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
 {
     OperationContext.Current.Extensions.Add(new RequestContext());
     return(null);
 }
Example #33
0
        object IDispatchMessageInspector.AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            ModuleProc PROC = new ModuleProc(this.DYN_MODULE_NAME, "AfterReceiveRequest");

            try
            {
                this.InspectRequestMessage(ref request, channel, instanceContext);
            }
            catch (Exception ex)
            {
                Log.Exception(PROC, ex);
            }

            return(null);
        }
Example #34
0
 protected virtual void OnProcessRequestMessage(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel,
                                                System.ServiceModel.InstanceContext instanceContext, OperationContext context)
 {
 }
Example #35
0
 /// <summary>
 /// Not used.
 /// </summary>
 /// <param name="instanceContext"></param>
 /// <param name="instance"></param>
 public void ReleaseInstance(System.ServiceModel.InstanceContext instanceContext, object instance)
 {
     return;
 }
Example #36
0
 /// <summary>
 /// GetInstance is used to create an instance of ResourceService wrapped by the PolicyInjection framework.
 /// </summary>
 /// <param name="instanceContext"></param>
 /// <returns>Contract.IResourceService</returns>
 public object GetInstance(System.ServiceModel.InstanceContext instanceContext)
 {
     return(GetInstance(instanceContext, null));
 }
Example #37
0
        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            object correlationState = null;

            HttpRequestMessageProperty requestMessage = request.Properties["httpRequest"] as HttpRequestMessageProperty;

            if (request == null)
            {
                throw new InvalidOperationException("Invalid request type.");
            }
            string authHeader = requestMessage.Headers["Authorization"];

            if (string.IsNullOrEmpty(authHeader) || !Authenicate(OperationContext.Current.IncomingMessageHeaders.To.AbsoluteUri, requestMessage.Method, authHeader))
            {
                WcfErrorResponseData error = new WcfErrorResponseData(HttpStatusCode.Forbidden);
                correlationState = error;
                request          = null;
            }

            return(correlationState);
        }
Example #38
0
 public DuplexChannelFactory(InstanceContext callbackInstance, ServiceEndpoint endpoint)
     : this((object)callbackInstance, endpoint)
 {
 }
        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            // Declare variables
            string Service     = "";
            string UserToken   = null;
            string ServiceCall = "";
            string Body        = "";

            // Make a copy of the message for viewing / data manipulation
            MessageBuffer buffer  = request.CreateBufferedCopy(Int32.MaxValue);
            Message       msgCopy = buffer.CreateMessage();

            // A message can only be consumed once, so make sure you  return a copy
            request = buffer.CreateMessage();

            // Get the XML content
            var strMessage = msgCopy.ToString();

            // Get the SOAP XML body content
            XmlDictionaryReader xrdr = msgCopy.GetReaderAtBodyContents();
            string bodyData          = xrdr.ReadOuterXml();

            // Replace the body placeholder with the actual SOAP body.
            strMessage = strMessage.Replace("... stream ...", bodyData);

            // Load the SOAP XML string into a new XML Document
            var doc = new XmlDocument();

            doc.LoadXml(strMessage);

            foreach (XmlNode node in doc.DocumentElement.ChildNodes)
            {
                if (node.Name == "s:Header")
                {
                    if (node.FirstChild.Name != "TokenHeader")
                    {
                        Service     = node.FirstChild.InnerText;
                        ServiceCall = node.LastChild.InnerText;
                    }
                    else
                    {
                        UserToken   = node.FirstChild.InnerText;
                        Service     = node.ChildNodes.Item(1).InnerText;
                        ServiceCall = node.LastChild.InnerText;
                    }
                }

                if (node.Name == "s:Body")
                {
                    Body = node.InnerXml;
                }
            }

            // The ExemptServiceCalls Class contains a list of services that we to NOT want to keep a record of.
            // The properties of this class are converted into a list.

            var serviceList = ExemptServiceCalls.GetExemptServices();

            // Query the list to see if it contains an exempt service call
            var containsExemptService = serviceList.Contains(ServiceCall);

            // If the class does not contain en exempt service call, enter it into the database
            if (containsExemptService == false)
            {
                // Insert Into Activity Log table
                BLL.ActivityLog.InsertIntoActivityLog(Service, ServiceCall, Body, strMessage, UserToken);
            }

            return(null);
        }
Example #40
0
 public DuplexChannelFactory(InstanceContext callbackInstance, string endpointConfigurationName, EndpointAddress remoteAddress)
     : this((object)callbackInstance, endpointConfigurationName, remoteAddress)
 {
 }
Example #41
0
        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            // Check to see if we have a request as part of this message
            var headerIndex = request.Headers.FindHeader(MiniProfilerRequestHeader.HeaderName, MiniProfilerRequestHeader.HeaderNamespace);

            if (headerIndex >= 0)
            {
                var requestHeader = request.Headers.GetHeader <MiniProfilerRequestHeader>(headerIndex);
                if (requestHeader != null)
                {
                    MiniProfiler.Settings.ProfilerProvider = new WcfRequestProfilerProvider();
                    MiniProfiler.Start();
                    return(requestHeader);
                }
            }

            return(null);
        }
Example #42
0
 public DuplexChannelFactory(InstanceContext callbackInstance, Binding binding, EndpointAddress remoteAddress)
     : this((object)callbackInstance, binding, remoteAddress)
 {
 }
Example #43
0
 public DuplexChannelFactory(InstanceContext callbackInstance, string endpointConfigurationName)
     : this((object)callbackInstance, endpointConfigurationName)
 {
 }
Example #44
0
 public TChannel CreateChannel(InstanceContext callbackInstance)
 {
     return(CreateChannel(callbackInstance, CreateEndpointAddress(this.Endpoint), null));
 }
Example #45
0
 public DuplexChannelFactory(InstanceContext callbackInstance, Binding binding)
     : this((object)callbackInstance, binding)
 {
 }
Example #46
0
            public CloseAsyncResult(TimeSpan timeout, AsyncCallback callback, object state, InstanceContext instanceContext)
                : base(callback, state)
            {
                _timeoutHelper   = new TimeoutHelper(timeout);
                _instanceContext = instanceContext;
                IAsyncResult result = _instanceContext._channels.BeginClose(_timeoutHelper.RemainingTime(), PrepareAsyncCompletion(new AsyncCompletion(CloseChannelsCallback)), this);

                if (result.CompletedSynchronously && CloseChannelsCallback(result))
                {
                    base.Complete(true);
                }
            }
Example #47
0
 //InstanceContext overloads
 public DuplexChannelFactory(InstanceContext callbackInstance)
     : this((object)callbackInstance)
 {
 }
Example #48
0
 public RegistrationProxy(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
     : base(callbackInstance, endpointConfigurationName, remoteAddress)
 {
 }
 public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
 {
     return(null);
 }
Example #50
0
 public RegistrationProxy(System.ServiceModel.InstanceContext callbackInstance)
     : base(callbackInstance)
 {
 }
Example #51
0
 public RegistrationProxy(System.ServiceModel.InstanceContext callbackInstance, System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress)
     : base(callbackInstance, binding, remoteAddress)
 {
 }
Example #52
0
        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            if (request.Headers.MessageVersion != MessageVersion.None)
            {
                // Check to see if we have a request as part of this message
                var headerIndex = request.Headers.FindHeader(MiniProfilerRequestHeader.HeaderName, MiniProfilerRequestHeader.HeaderNamespace);
                if (headerIndex >= 0)
                {
                    var requestHeader = request.Headers.GetHeader <MiniProfilerRequestHeader>(headerIndex);
                    if (requestHeader != null)
                    {
                        MiniProfiler.Settings.ProfilerProvider = new WcfRequestProfilerProvider();
                        MiniProfiler.Start();
                        return(requestHeader);
                    }
                }
            }
            else if (_http || WebOperationContext.Current != null || channel.Via.Scheme == "http" | channel.Via.Scheme == "https")
            {
                _http = true;

                if (request.Properties.ContainsKey(HttpRequestMessageProperty.Name))
                {
                    var property = (HttpRequestMessageProperty)request.Properties[HttpRequestMessageProperty.Name];

                    var text = property.Headers[MiniProfilerRequestHeader.HeaderName];
                    if (!string.IsNullOrEmpty(text))
                    {
                        var header = MiniProfilerRequestHeader.FromHeaderText(text);
                        MiniProfiler.Settings.ProfilerProvider = new WcfRequestProfilerProvider();
                        MiniProfiler.Start();
                        return(header);
                    }
                }
            }
            else
            {
                throw new InvalidOperationException("MVC Mini Profiler does not support EnvelopeNone unless HTTP is the transport mechanism");
            }

            return(null);
        }
Example #53
0
 public RegistrationProxy(System.ServiceModel.InstanceContext callbackInstance, string endpointConfigurationName)
     : base(callbackInstance, endpointConfigurationName)
 {
 }
        public object AfterReceiveRequest(ref Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            XmlConfigurator.Configure(new System.IO.FileInfo(Path.Combine(AssemblyDirectory, "log4netConfig.config")));
            MessageBuffer buffer      = request.CreateBufferedCopy(Int32.MaxValue);
            Message       copyRequest = buffer.CreateMessage();
            StringBuilder sb          = new StringBuilder();

            using (System.Xml.XmlWriter xw = System.Xml.XmlWriter.Create(sb))
            {
                copyRequest.WriteMessage(xw);
                xw.Flush();
                xw.Close();
            }
            log.Info(sb.ToString());
            request = buffer.CreateMessage();
            return(null);
        }
        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            if (OperationContext.Current.IncomingMessageHeaders.Action.Contains("Login"))
            {
                return(null);
            }
            string token = GetHeaderValue("token");

            if (string.IsNullOrEmpty(token))
            {
                //AppContext.CurrentSession.UserId = "0000001";
                //AppContext.CurrentSession.UserName = "******";
                //AppContext.CurrentSession.DepartmentId = "DEPT01";
                //AppContext.CurrentSession.DepartmentName = "部门01";
                //throw new YEF.Core.Exceptions.NoSessionException("没有登录或长时间没有进行任何操作,请重新登录。");
            }
            if (token != null)
            {
            }
            return(null);
        }
Example #56
0
 public object AfterReceiveRequest(ref Message request, System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
 {
     if (!request.IsFault && !request.IsEmpty)
     {
         // TODO: Implement auth key message behavior.
         //var commands = RdlCommandGroup.FromBytes(request.GetBody<byte[]>());
         //if (commands.Count > 0)
         //{
         //    if (!String.IsNullOrEmpty(commands.AuthKey))
         //    {
         //        AuthKey key = AuthKey.Get(commands.AuthKey);
         //        Server s = new Server();
         //        if (!s.World.Provider.ValidateAuthKey(key))
         //        {
         //            throw new FaultException(Resources.Resource.AuthorizationFailed);
         //        }
         //    }
         //}
     }
     return(null);
 }
 public void NotifyIdle(InstanceContextIdleCallback callback, System.ServiceModel.InstanceContext instanceContext)
 {
 }