private XDocument SerialiseXmlRpcResponse(object data) { var exception = data as Exception; if (exception != null) { return(new XDocument( new XElement("methodResponse", new XElement("fault", new XElement("value", new XElement("string", exception.Message) ) ) ) )); } else { return(new XDocument( new XElement("methodResponse", new XElement("params", new XElement("param", XmlRpcData.SerialiseValue(data)) ) ) )); } }
public override void OnActionExecuting(ActionExecutingContext filterContext) { XDocument xDoc = filterContext.HttpContext.Items["Xml-Rpc-Document"] as XDocument; //Set the parameter values from the XML-RPC request XML if (xDoc != null) { var xmlParams = xDoc.Document.Element("methodCall") .Element("params") .Elements("param") .ToArray(); int index = 0; foreach (var paramDescriptor in filterContext.ActionDescriptor.Parameters) { var node = xmlParams[index].Element("value"); filterContext.ActionArguments[paramDescriptor.Name] = XmlRpcData.DeserialiseValue(node, paramDescriptor.ParameterType); index++; } } base.OnActionExecuting(filterContext); }