/// <summary> /// Maps the properties of a <see cref="ServiceEndpoint"/> instance into a /// <see cref="HttpEndpointCommunication"/> instance. /// </summary> /// <param name="endpoint">The endpoint to map.</param> /// <param name="commsEvent">The instance to populate. If <see langword="null"/> a new instance will be created.</param> /// <returns>The updated <paramref name="commsEvent"/>.</returns> internal HttpEndpointCommunication ToHttpEndpointCommunication(ServiceEndpoint endpoint, HttpEndpointCommunication commsEvent = null) { commsEvent = commsEvent ?? new HttpEndpointCommunication(); commsEvent.ServiceEndpointId = endpoint.Id; commsEvent.Timestamp = DateTime.Now; commsEvent.RequestUrl = endpoint.Url; commsEvent.RequestMethod = endpoint.Method; commsEvent.RequestFormat = endpoint.RequestFormat; commsEvent.ResponseFormat = endpoint.ResponseFormat; return commsEvent; }
/// <summary> /// Saves an endpoint communication event. /// </summary> /// <param name="communication">The communication event to save.</param> protected override void DoLogCommunication(HttpEndpointCommunication communication) { MongoCollection<BsonDocument> collection = this.Database.GetCollection(iApplyDb.ServiceEndpointCommunicationLog._COLLECTION_NAME); BsonDocument document = BsonConverter.ConvertToBsonViaJson(communication); collection.Save(document); }
/// <summary> /// Saves an endpoint communication event. /// </summary> /// <param name="communication">The communication event to save.</param> protected abstract void DoLogCommunication(HttpEndpointCommunication communication);
/// <summary> /// Saves an endpoint communication event. /// </summary> /// <param name="communication">The communication event to save.</param> public void LogCommunication(HttpEndpointCommunication communication) { this.DoLogCommunication(communication); }
/// <summary> /// Logs a <see cref="HttpEndpointCommunication"/> event. /// </summary> /// <param name="communication">The event to log.</param> public void LogCommunication(HttpEndpointCommunication communication) { this.dataAccess.SaveEndpointCommunication(communication); }
/// <summary> /// Sends a request to a service endpoint and returns the <see cref="HttpWebResponse"/>. /// </summary> /// <param name="endpoint">The endpoint definition.</param> /// <param name="commsEvent">Tracks the communication event.</param> /// <param name="application">The application to map.</param> /// <param name="requestFieldMap">The list of mapped fields for the request.</param> /// <returns>The <see cref="HttpWebResponse"/>.</returns> private HttpWebResponse DoSendRequest(ServiceEndpoint endpoint, HttpEndpointCommunication commsEvent, Application application, MappedFieldList requestFieldMap) { string requestBody; HttpWebRequest request = new HttpWebRequestFactory().Create(endpoint, application, requestFieldMap, out requestBody); request.Timeout = Convert.ToInt32(TimeSpan.FromSeconds(this.TimeoutSeconds).TotalMilliseconds); commsEvent.RequestHeaders = request.Headers.ToDictionary(); commsEvent.RequestContent = requestBody; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); commsEvent.ResponseHeaders = response.Headers.ToDictionary(); return response; }
/// <summary> /// Does nothing. /// </summary> /// <param name="communication">The event to swallow.</param> public void LogCommunication(HttpEndpointCommunication communication) { }