private void WriteFileCustom(byte[] body, bool request, string logPath) { logPath = Path.Combine(logPath, "GetForecastByLocation"); var fileNameFactory = new FileNameFactory(); try { var message = SoapMessage.Parse(body, request); fileNameFactory.AddSegment(message.GetOperationName()); fileNameFactory.AddSegment(message.GetNodeValue("body", "GetForecastByLocation", "Location")); fileNameFactory.AddSegment(message.GetNodeValue("body", "GetForecastByLocationResponse", "GetForecastByLocationResult", "WeatherReport", "Location")); fileNameFactory.AddSegment(message.GetNodeValue("body", "GetForecastByLocationResponse", "GetForecastByLocationResult", "WeatherReport", "Temperature")); fileNameFactory.AddDirection(request); string indentedXml = message.GetIndentedXml(); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), indentedXml, null, logPath); } catch (FileSystemAcccesDeniedException) { throw; } catch (Exception ex) { fileNameFactory.AddSegment("ERROR"); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), null, body, logPath); fileNameFactory.AddSegment("exception"); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), ex.ToString(), null, logPath); } }
// this custom handling method looks for 'GetForecastByLocation' only private void WriteFileCustom(byte[] body, bool request, string logPath) { const string operationNameToLog = "GetForecastByLocation"; logPath = Path.Combine(logPath, operationNameToLog); var fileNameFactory = new FileNameFactory(); try { var message = SoapMessage.Parse(body, request); string operationName = message.GetOperationName(); if (operationName != operationNameToLog) { return; } // _dbLoggingTest.LogToDatabase(message, request); // uncomment to see simple DB logging fileNameFactory.AddSegment(message.GetNodeValue("Body / GetForecastByLocation / Location")); fileNameFactory.AddSegment(message.GetNodeValue("Body / GetForecastByLocationResponse / GetForecastByLocationResult / WeatherReport / Location")); fileNameFactory.AddSegment(message.GetNodeValue("Body / GetForecastByLocationResponse / GetForecastByLocationResult / WeatherReport / Temperature")); fileNameFactory.AddDirection(request); string indentedXml = message.GetIndentedXml(); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), indentedXml, null, logPath); } catch (FileSystemAcccesDeniedException) { throw; } catch (Exception ex) { fileNameFactory.AddSegment("ERROR"); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), null, body, logPath); fileNameFactory.AddSegment("exception"); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), ex.ToString(), null, logPath); } }
private void WriteFileCustom(byte[] body, bool request, string logPath) { const string operationNameToLog = "GetLastReportByLocation"; logPath = Path.Combine(logPath, operationNameToLog); var fileNameFactory = new FileNameFactory(); try { var message = SoapMessage.Parse(body, request); string operationName = message.GetOperationName(); if (operationName != operationNameToLog) { return; } fileNameFactory.AddSegment(operationName); fileNameFactory.AddSegment(message.GetNodeValue("Body", "GetLastReportByLocation", "Location")); // fileNameFactory.AddSegment(message.GetNodeValue("Body", "SendReport", "report", "location")); // fileNameFactory.AddSegment(message.GetNodeValue("Body", "GetForecastByLocation", "location")); fileNameFactory.AddDirection(request); string indentedXml = message.GetIndentedXml(); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), indentedXml, null, logPath); } catch (FileSystemAcccesDeniedException) { throw; } catch (Exception ex) { fileNameFactory.AddSegment("ERROR"); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), null, body, logPath); fileNameFactory.AddSegment("exception"); SoapLoggerTools.WriteFile(fileNameFactory.GetFileName(), ex.ToString(), null, logPath); } }