Exemplo n.º 1
0
        private byte[] GetServiceSideErrorBody(Exception ex, bool request)
        {
            if (request)
            {
                //this can happen only with default handler on service side
                //typically when lacking access to file system
                SoapLoggerService.SetRequestException(ex);

                //in order to force HTTP 500 Internal Server Error and avoid processing
                //we overwrite request with deliberately invalid body
                return(ErrorBody.InvalidRequest());
            }

            // response
            string message = null;

            if (ex is LoggerException)
            {
                message = ex.Message;
            }
            else
            {
                message = ex.ToString();
            }

            string soapFault = ErrorBody.CreateSoapFaultResponse(message);

            byte[] errorBody = Encoding.UTF8.GetBytes(soapFault);
            return(errorBody);
        }
Exemplo n.º 2
0
        protected override byte[] GetRequestErrorBody(Exception ex)
        {
            //this can happen only with default handler
            //typically when lacking access to file system
            SoapLoggerService.SetRequestException(ex);

            //in order to force HTTP 500 Internal Server Error and avoid processing
            //we overwrite request with deliberately invalid body
            return(ErrorBody.GetSoapInvalidRequest());
        }
Exemplo n.º 3
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 WeatherServiceEuropeCustomHandler()
 {
     // you need just this line in web-service constructor to apply your custom handlers to all operation methods
     // default WCF behavior is assumed here - creating new class instance 'per call'
     SoapLoggerService.CallCustomHandlers(this);
 }
Exemplo n.º 5
0
 protected override void HandleResponse(byte[] body)
 {
     SoapLoggerService.CallResponseCallback(body, settings);
 }
Exemplo n.º 6
0
 protected override void HandleRequest(byte[] body)
 {
     SoapLoggerService.SetRequestBody(body);
 }
 public override WeatherReport[] GetForecastByLocation(string location, int days)
 {
     SoapLoggerService.CallCustomHandlers(new CustomHandler_GetForecastByLocation());
     return(base.GetForecastByLocation(location, days));
 }
 public override WeatherReport GetLastReportByLocation(string location)
 {
     SoapLoggerService.CallCustomHandlers(this);
     return(base.GetLastReportByLocation(location));
 }
 public override long SendReport(WeatherReport report)
 {
     SoapLoggerService.CallCustomHandlers(this);
     return(base.SendReport(report));
 }