Ejemplo n.º 1
0
        //- @ProcessRequest -//
        public void ProcessRequest(HttpContext context)
        {
            if (!ReflectionCache.ContainsSpecificMethodCatalog(this.TypeFullName))
            {
                TypeScanner.SetMappedMethods(this.GetType());
            }
            Stream stream = context.Request.InputStream;

            if (context.Request.Url.AbsoluteUri.EndsWith("?smd"))
            {
                if (!ReflectionCache.ContainsSpecificServiceDescription(this.TypeFullName))
                {
                    String url = context.Request.Url.AbsoluteUri;
                    ReflectionCache.AddServiceDescription(this.TypeFullName, DescriptionCreator.CreateDescription(this.GetType(), url));
                }
                DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(DojoServiceDescription));
                s.WriteObject(context.Response.OutputStream, ReflectionCache.GetSpecificServiceDescription(this.TypeFullName));
            }
            else
            {
                if (stream != null && stream.Length > 0)
                {
                    DataContractJsonSerializer s = new DataContractJsonSerializer(typeof(DojoMessage));
                    DojoMessage o = null;
                    try
                    {
                        o = (DojoMessage)s.ReadObject(stream);
                    }
                    catch
                    {
                        context.Response.Write("Error in JSON message");
                    }
                    if (o != null)
                    {
                        Object r = CallServiceMethod(o);
                        s.WriteObject(context.Response.OutputStream, r);
                    }
                }
            }
        }