Пример #1
0
        public ActionResult ServiceEndpoint(XRpcMethodCall methodCall) {
            Logger.Debug("XmlRpc methodName {0}", methodCall.MethodName);
            var methodResponse = Dispatch(methodCall);

            if (methodResponse == null)
                throw new HttpException(500, "TODO: xmlrpc fault");

            
            var settings = new XmlWriterSettings {
                Encoding = Encoding.UTF8,
                OmitXmlDeclaration = false,
                Indent = true
            };

            // save to an intermediate MemoryStream to preserve the encoding declaration
            using (var stream = new MemoryStream()) {
                using (XmlWriter w = XmlWriter.Create(stream, settings)) {
                    var result = _writer.MapMethodResponse(methodResponse);
                    result.Save(w);
                }

                var content = Encoding.UTF8.GetString(stream.ToArray());
                return Content(content, "text/xml");
            }
        }
Пример #2
0
        public ActionResult ServiceEndpoint(XRpcMethodCall methodCall) {
            Logger.Debug("XmlRpc methodName {0}", methodCall.MethodName);
            var methodResponse = Dispatch(methodCall);

            if (methodResponse == null)
                throw new HttpException(500, "TODO: xmlrpc fault");

            var content = _writer.Map(methodResponse).ToString();
            return Content(content, "text/xml");
        }
Пример #3
0
        private XRpcMethodResponse Dispatch(XRpcMethodCall request) {
            var context = new XmlRpcContext { ControllerContext = ControllerContext, HttpContext = HttpContext, Request = request };
            try {
                foreach (var handler in _xmlRpcHandlers) {
                    handler.Process(context);
                }
            }
            catch (OrchardCoreException e) {
                // if a core exception is raised, report the error message, otherwise signal a 500
                context.Response =  context.Response ?? new XRpcMethodResponse();
                context.Response.Fault = new XRpcFault(0, e.LocalizedMessage.ToString());
            }

            return context.Response;
        }
Пример #4
0
 private XRpcMethodResponse Dispatch(XRpcMethodCall request) {
     var context = new XmlRpcContext { ControllerContext = ControllerContext, HttpContext = HttpContext, Request = request };
     foreach (var handler in _xmlRpcHandlers)
         handler.Process(context);
     return context.Response;
 }