public void WriteResponseToStream(LegacyResponse legacyResponse, Stream writeStream) { var request = legacyResponse.Request; var body = request.GetSoapBody(); var operationElement = _legacyMessageParser.GetOperationElement(body); var operationElementName = operationElement.Name; var namespaceName = operationElementName.NamespaceName; var operationName = operationElementName.LocalName; var operationResultInnerElement = new XElement(string.Concat("{", namespaceName, "}", operationName, "Result")); var processResult = legacyResponse.ProcessingResult; if (processResult != null) { operationResultInnerElement.Add(processResult); } var operationResultOuterElement = new XElement(string.Concat("{", namespaceName, "}", operationName, "Response")); operationResultOuterElement.Add(operationResultInnerElement); operationElement.ReplaceWith(operationResultOuterElement); using (var outWriter = new XmlTextWriter(writeStream, Encoding.UTF8)) { request.WriteTo(outWriter); outWriter.Flush(); } }
public virtual LegacyResponse ProcessLegacyMessage(XDocument request) { var operationElement = _legacyMessageParser.GetOperationElement(request); var opName = operationElement.Name.LocalName; foreach (var legacyMessageProcessingStrategy in _legacyMessageProcessingStrategies) { if (legacyMessageProcessingStrategy.CanProcess(opName)) { var legacyResponse = new LegacyResponse { Request = request, ProcessingResult = legacyMessageProcessingStrategy.Execute(operationElement) }; return(legacyResponse); } } throw new NotSupportedException(opName); }