public SoapResultDescription Execute(SoapCommandDescription[] soapCommands) { IServerCommandDescription<XElement>[] processingCommands; if (soapCommands == null || soapCommands.Length == 0) throw new FaultException("SOAP commands missing."); if (soapCommands.Where(sc => sc.CommandName == null || ServerCommands.Find(sc.CommandName) == null).Any()) { var unknownCommand = (from sc in soapCommands where sc.CommandName == null || ServerCommands.Find(sc.CommandName) == null select sc.CommandName) .First(); throw new FaultException("Unknown command: " + unknownCommand); } processingCommands = PrepareCommands(soapCommands).ToArray(); var result = ProcessingEngine.Execute<XElement, XElement>(processingCommands); if (result.Status == HttpStatusCode.ServiceUnavailable) HttpRuntime.UnloadAppDomain(); if (result.Status == HttpStatusCode.InternalServerError || result.ExecutedCommandResults == null) throw new FrameworkException(result.Message); if ((int)result.Status >= 300) throw new FaultException(result.Message); return ConvertToSoapResult(result); }
private IEnumerable<IServerCommandDescription<XElement>> PrepareCommands(SoapCommandDescription[] soapCommands) { return from sc in soapCommands select SoapCommandDescription<XElement>.Create( sc.RequestID, sc.Data != null ? XElement.Parse(sc.Data) : null, ServerCommands.Find(sc.CommandName)); }