public static void AddMissingDefaultDataToTID(ITID tid, MessageHeaders headers, ServiceDescription desc) { tid.Set(TIDField.MESSAGEID, Guid.NewGuid().ToString()); tid.Set(TIDField.MESSAGEVERSION, GetMessageVersion(desc)); tid.Set(TIDField.SERVICENAME, GetServiceName(desc)); tid.Set(TIDField.OPERATIONNAME, GetOperationName(headers)); }
/// <summary> /// This will retrieve the ParamList (if there is one) from the message headers /// and set that as the ParamList for the TID. /// </summary> /// <param name="tid"></param> /// <param name="headers"></param> public static void AddParamListFromMessageToTID(ITID tid, MessageHeaders headers) { Dictionary <string, string> paramList = GetParamList(headers); if (paramList != null) { tid.Set(TIDField.PARAMLIST, paramList); } }
// This method updates the MessageSeqNumber in the IncomingMessage headers so it is // up-to-date for things later in the process during the multi-hop scenario. private static void WriteMessageSeqNumToIncomingHeaders(int iNewSeqNumber) { if (OperationContext.Current != null && OperationContext.Current.IncomingMessageHeaders != null) { MessageHeaders headers = OperationContext.Current.IncomingMessageHeaders; ITID tid = TIDFactory.GetTIDFromMessage(OperationContext.Current.IncomingMessageHeaders); if (tid != null) { tid.Set(TIDField.MESSAGESEQNUMBER, iNewSeqNumber); ASAMessageInspectionHelper.AddTIDHeader(tid, ref headers); } } }
/// <summary> /// o AfterReceiveReply(): This method will be used to audit TID information /// upon receiving a reply from the service. This method will: /// - Retrieve TID information from the header of the received message /// - Update TID fields for situation of a reply being received. This will /// be done by the ASAMessageInspectionHelper.GetAfterReceiveReplyData() method. /// - Call the TID class’ GetRecvTID() method /// - send TID xml to the Logger for auditing. /// </summary> /// <param name="reply"></param> /// <param name="correlationState"></param> public void AfterReceiveReply(ref Message reply, object correlationState) { try { //load Parameters with ASA settings Parameters.Instance.SectionName = "asa"; if (Parameters.Instance.EnableClientResponseAudit == true) { ITID tid = TIDFactory.GetTIDFromMessage(reply.Headers); //added for QC 2364: populate some TID info even if service didnt return one, // so long as we have an opCtx to pull some info from. if (tid == null) { OperationContext opCtx = OperationContext.Current; if (opCtx != null) //this call is from inside a service { MessageHeaders headers = reply.Headers; tid = ASAMessageInspectionHelper.CreateNewTID(); Hashtable mapProps = ASAMessageInspectionHelper.GetReplyDataWhenNoTidWasFound(tid, headers); tid = TIDFactory.GetCreateTID(mapProps); ASAMessageInspectionHelper.AddTIDHeader(tid, ref headers); } } // update the TID if (tid != null) { MessageHeaders headers = reply.Headers; //populate hashtable with fields needed when receiving the reply message. Hashtable mapProps = ASAMessageInspectionHelper.GetAfterReceiveReplyData(tid, headers); //call update the tid for sending. tid = TIDFactory.GetRecvTID(headers, mapProps); ASAMessageInspectionHelper.AddTIDHeader(tid, ref headers); // Check for config file entry "Enable_ClientResponseAudit" //audit the TID information in 'tid' using the new ASA Logger string strTID = ASAMessageInspectionHelper.GetTIDString(headers); Log.LogTID(strTID); //Update MessageSequenceNumber within the OperationContext's tid for multihop scenario. OperationContext opCtx = OperationContext.Current; if (opCtx != null) { ITID tidFromOpContext = TIDFactory.GetTIDFromMessage(opCtx.IncomingMessageHeaders); if (tidFromOpContext != null) { tidFromOpContext.Set(TIDField.MESSAGESEQNUMBER, ((int)tid.Get(TIDField.MESSAGESEQNUMBER))); MessageHeaders opCtxHeaders = opCtx.IncomingMessageHeaders; ASAMessageInspectionHelper.AddTIDHeader(tidFromOpContext, ref opCtxHeaders); } } } else { //Log error Log.Error("TID object was not created properly by this interception point on the client or service:" + Environment.MachineName, this.strCorrelationIDForLogging.ToString()); //TODO: get URL of the service it's returning from? } } } catch (ASAException exASA) { // log exception, then swallow it. Log.Error("Error in AfterReceiveReply:" + exASA.Message + " Error_code:" + exASA.ExceptionError_id, exASA); } catch (Exception ex) { // log exception, then swallow it. Log.Error("Error in AfterReceiveReply", ex); } }