public object BeforeSendRequest(ref Message request, System.ServiceModel.IClientChannel channel) { request.Headers.Add(MessageHeader.CreateHeader("Passport", "ms", PassportTicket)); #if PASSPORT_HEADER_ANALYSIS Traces.WebService_TraceEvent(TraceEventType.Information, 2, request.ToString()); #endif return(null); }
/// <summary> /// Erlaubt den Aufruf von Methoden mit einer bestimmten Anzahl an Wiederholungen /// </summary> /// <param name="retryCount">Die Anzahl an max. Wiederholungen, bis das Ergebnis Ok sein muss.</param> /// <param name="func"></param> /// <returns></returns> public TResult RetryCall <TResult>(Func <TResult> func, uint retryCount = 1u) { try { return(func()); } catch (Exception exp) { if (string.Equals(exp.Message, "Passport Header Not Found", StringComparison.OrdinalIgnoreCase)) { // CheckTicket... var forumService = _service as ClientBase <IForumsService>; if (forumService != null) { var ai = forumService.Endpoint.Behaviors.FirstOrDefault(p => p is AuthenticationInspector) as AuthenticationInspector; if (ai != null) { Traces.WebService_TraceEvent(TraceEventType.Information, 1, "CheckTicket: {0}", ai.CheckTicket()); } } } throw; } #if PASSPORT_HEADER_ANALYSIS uint cnt = 0; while (true) { try { return(func()); } catch (Exception exp) { Traces.WebService_TraceEvent(TraceEventType.Error, 1, "Error calling Web-Service: {0}", NNTPServer.Traces.ExceptionToString(exp)); // Workaround... if (string.Equals(exp.Message, "Passport Header Not Found", StringComparison.OrdinalIgnoreCase) == false) { throw; } if (cnt >= retryCount) { throw; } // CheckTicket... var forumService = _service as ClientBase <IForumsService>; if (forumService != null) { var ai = forumService.Endpoint.Behaviors.FirstOrDefault(p => p is AuthenticationInspector) as AuthenticationInspector; if (ai != null) { Traces.WebService_TraceEvent(TraceEventType.Information, 1, "CheckTicket: {0}", ai.CheckTicket()); } } Traces.WebService_TraceEvent(TraceEventType.Information, 1, "Try to re-authenticate"); RaiseAuthenticationError(); cnt++; } // catch } // while #endif }
public void AfterReceiveReply(ref Message reply, object correlationState) { #if PASSPORT_HEADER_ANALYSIS Traces.WebService_TraceEvent(TraceEventType.Information, 3, reply.ToString()); #endif }