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);
            }
        }
Beispiel #2
0
        internal static void CallResponseCallback(byte[] responseBody, SoapLoggerSettings settings)
        {
            if (_requestBody != null)
            {
                //something went wrong, either pipeline execution didn't reach web-service method
                //or web-service method didn't call 'ReadRequestSetResponseCallback'

                //TODO determine case and log both files for first case

                var requestBody = _requestBody;
                _requestBody = null;

                SoapLoggerTools.WriteFileDefault(requestBody, true, settings.LogPath, false);
                SoapLoggerTools.WriteFileDefault(responseBody, false, settings.LogPath, false);

                //TODO add logging error message to file

                throw new LoggerException("something went wrong, either pipeline execution didn't reach web-service method or web-service method didn't execute 'SoapLoggerService.CallCustomHandlers'");
            }

            try
            {
                _service.HandleResponseBodyCallback(responseBody, settings);
            }
            finally
            {
                _service = null;
            }
        }
Beispiel #3
0
        public virtual void HandleBody(byte[] body, bool request)
        {
            SoapLoggerTools.WriteFileDefault(body, request, _settings.LogPath, _settings.SaveOriginalBinaryBody);

            if (!_settings.UseCustomHandler && _settings.IsClient && request)
            {
                SoapLoggerClient.CallCustomHandlersDisabledCallback(_settings);
            }
        }
        // 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);
            }
        }
Beispiel #6
0
        //Debug.QuickWatch: Encoding.UTF8.GetString(body)

        internal void HandleBody(byte[] body, bool request)
        {
            if (settings.IsService && request)
            {
                SoapLoggerService.SetSettings(settings);
            }

            if (settings.IsService && !request)
            {
                var requestException = SoapLoggerService.GetRequestException();

                if (requestException != null)
                {
                    throw requestException;
                }
            }

            if (settings.UseCustomHandler)
            {
                if (request)
                {
                    HandleRequest(body);
                }
                else
                {
                    HandleResponse(body);
                }
            }
            else
            {
                if (settings.IsClient && request)
                {
                    SoapLoggerClient.CallCustomHandlersDisabledCallback(settings);
                }

                //default handler
                SoapLoggerTools.WriteFileDefault(body, request, settings.LogPath);
            }
        }
 public void HandleResponseBodyCallback(byte[] responseBody, SoapLoggerSettings settings)
 {
     SoapLoggerTools.WriteFileDefault(responseBody, false, settings.LogPath);
 }
 public void HandleRequestBody(byte[] requestBody, SoapLoggerSettings settings)
 {
     SoapLoggerTools.WriteFileDefault(requestBody, true, settings.LogPath);
 }