private void ProcessJsvRequest(string url, string operationName, string httpMethod, NameValueCollection queryString, Stream inputStream, HttpListenerResponseWrapper response)
        {
            try
            {
                var request = JsvHandlerBase.CreateRequest(operationName, httpMethod, queryString, null, inputStream);

                var isDebugRequest = queryString["debug"] != null;

                var writeFn = isDebugRequest
                                        ? (Func <object, string>)JsvFormatter.SerializeAndFormat
                                        : TypeSerializer.SerializeToString;

                var contentType = isDebugRequest ? ContentType.PlainText : ContentType.JsvText;

                if (url.Contains("/jsv/syncreply/"))
                {
                    var result = ExecuteService(request, EndpointAttributes.SyncReply | EndpointAttributes.Jsv | HttpMethods.GetEndpointAttribute(httpMethod));
                    response.WriteToResponse(result, writeFn, contentType);
                }
                else if (url.Contains("/jsv/asynconeway/"))
                {
                    ExecuteService(request, EndpointAttributes.AsyncOneWay | EndpointAttributes.Jsv | HttpMethods.GetEndpointAttribute(httpMethod));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                response.WriteJsvErrorToResponse(operationName, ex.Message, ex);
            }
        }
        protected override void ProcessRequest(HttpListenerContext context)
        {
            if (string.IsNullOrEmpty(context.Request.RawUrl))
            {
                return;
            }

            var operationName = context.Request.GetOperationName();
            var request       = CreateRequest(context.Request, operationName);

            const EndpointAttributes endpointAttributes = EndpointAttributes.SyncReply | EndpointAttributes.Xml;

            var result = ExecuteService(request, endpointAttributes);

            var response = new HttpListenerResponseWrapper(context.Response);

            response.WriteToResponse(result, x => DataContractSerializer.Instance.Parse(result), ContentType.Xml);
        }
        private void ProcessJsonRequest(string url, string operationName, string httpMethod, NameValueCollection queryString, Stream inputStream, HttpListenerResponseWrapper response)
        {
            try
            {
                var request = JsonHandlerBase.CreateRequest(operationName,
                                                            httpMethod, queryString, null, inputStream);

                if (url.Contains("/json/syncreply/"))
                {
                    var result = ExecuteService(request, EndpointAttributes.SyncReply | EndpointAttributes.Json | HttpMethods.GetEndpointAttribute(httpMethod));
                    response.WriteToResponse(result, x => JsonDataContractSerializer.Instance.Parse(result), ContentType.Json);
                }
                else if (url.Contains("/json/asynconeway/"))
                {
                    var result = ExecuteService(request, EndpointAttributes.AsyncOneWay | EndpointAttributes.Json | HttpMethods.GetEndpointAttribute(httpMethod));
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                response.WriteJsonErrorToResponse(operationName, ex.Message, ex);
            }
        }