/// <summary> /// Logs the response information. /// </summary> /// <param name="response">The message to be transformed into types /// and handed back to the client application.</param> /// <param name="correlationState">Correlation state data returned by BeforeSendRequest</param> public void AfterReceiveReply(ref Message response, object correlationState) { object httpProp; if (!response.Properties.TryGetValue(HttpResponseMessageProperty.Name, out httpProp)) { httpProp = new HttpResponseMessageProperty(); response.Properties.Add(HttpResponseMessageProperty.Name, httpProp); } HttpResponseMessageProperty responseProperties = (HttpResponseMessageProperty)httpProp; this.responseInfo = new ResponseInfo() { Headers = responseProperties.Headers, Body = GetMessageBody(ref response), StatusCode = responseProperties.StatusCode }; this.user.CallListeners(requestInfo, responseInfo); }
/// <summary> /// Parses the body of the response and populates fields in the repsonse info. /// </summary> /// <param name="info">The response info for this SOAP call.</param> protected virtual void PopulateResponseInfo(ref ResponseInfo info) { XmlDocument xDoc = XmlUtilities.CreateDocument(info.Body); XmlNamespaceManager xmlns = new XmlNamespaceManager(xDoc.NameTable); xmlns.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/"); // Retrieve loggable headers. XmlNode headerNode = xDoc.SelectSingleNode("soap:Envelope/soap:Header/*", xmlns); if (headerNode != null && headerNode.Name == "ResponseHeader") { info.RequestId = RetrieveLoggableHeader(headerNode, "requestId"); long operations; if (long.TryParse(RetrieveLoggableHeader(headerNode, "operations"), out operations)) { info.OperationCount = operations; } long responseTime; if (long.TryParse(RetrieveLoggableHeader(headerNode, "responseTime"), out responseTime)) { info.ResponseTimeMs = responseTime; } } //Retrieve fault string (if one exists). XmlNode faultNode = xDoc.SelectSingleNode("soap:Envelope/soap:Body/soap:Fault/faultstring", xmlns); if (faultNode != null) { info.ErrorMessage = faultNode.InnerText; } }
/// <summary> /// Gets the formatted logs for an HTTP response. /// </summary> /// <param name="responseInfo">The response information.</param> /// <returns>The response log text.</returns> private string GetFormattedResponseLog(ResponseInfo responseInfo) { return(GetFormattedResponseLog(responseInfo, new HashSet <string>(), new DefaultBodyFormatter())); }
/// <summary> /// Logs an HTTP response. /// </summary> /// <param name="responseInfo">The response information.</param> public void LogResponse(ResponseInfo responseInfo) { LogResponse(responseInfo, new HashSet <string>(), new DefaultBodyFormatter()); }
/// <summary> /// Logs an HTTP response. /// </summary> /// <param name="responseInfo">The response information.</param> /// <param name="isFailure">True, if this is a failed response, false /// otherwise.</param> /// <param name="fieldsToMask">The list of fields to mask.</param> /// <param name="formatter">The formatter to be used for formatting the /// response logs.</param> public void LogResponse(ResponseInfo responseInfo, bool isFailure, ISet <string> fieldsToMask, TraceFormatter formatter) { LogResponseSummary(isFailure, ""); LogResponseDetails(responseInfo, fieldsToMask, formatter); }
/// <summary> /// Logs an HTTP response. /// </summary> /// <param name="responseInfo">The response information.</param> /// <param name="isFailure">True, if this is a failed response, false /// otherwise.</param> public void LogResponse(ResponseInfo responseInfo, bool isFailure) { LogResponse(responseInfo, isFailure, new HashSet <string>(), new DefaultBodyFormatter()); }
/// <summary> /// Handles the SOAP message. /// </summary> /// <param name="requestInfo">Request info.</param> /// <param name="responseInfo">Response info.</param> public virtual void HandleMessage(RequestInfo requestInfo, ResponseInfo responseInfo) { PerformLogging(requestInfo, responseInfo); }
/// <summary> /// Gets the formatted logs for an HTTP response. /// </summary> /// <param name="responseInfo">The response information.</param> /// <param name="headersToMask">The headers to mask.</param> /// <param name="bodyFormatter">The trace formatter to use when formatting /// the message. /// <returns>The response log text.</returns> private string GetFormattedResponseLog(ResponseInfo responseInfo, ISet<string> headersToMask, TraceFormatter traceFormatter) { StringBuilder builder = new StringBuilder(); builder.AppendFormat("\r\nResponse\r\n"); builder.AppendFormat("--------\r\n"); builder.AppendFormat("\r\n{0}\r\n\r\n{1}\r\n", GetFormattedHttpHeaderLogs(MaskHeaders(responseInfo.Headers, headersToMask), "\r\n"), traceFormatter.MaskContents(responseInfo.Body, headersToMask)); builder.AppendFormat("-----------------END API CALL-----------------------\r\n"); return builder.ToString(); }
/// <summary> /// Gets the formatted logs for an HTTP response. /// </summary> /// <param name="responseInfo">The response information.</param> /// <returns>The response log text.</returns> private string GetFormattedResponseLog(ResponseInfo responseInfo) { return GetFormattedResponseLog(responseInfo, new HashSet<string>(), new DefaultBodyFormatter()); }