/// <summary> /// Submits a direct request message to some remote party and blocks waiting for an immediately reply. /// </summary> /// <param name="request">The request message.</param> /// <returns>The response message, or null if the response did not carry a message.</returns> /// <remarks> /// Typically a deriving channel will override <see cref="CreateHttpRequest"/> to customize this method's /// behavior. However in non-HTTP frameworks, such as unit test mocks, it may be appropriate to override /// this method to eliminate all use of an HTTP transport. /// </remarks> protected virtual IProtocolMessage RequestInternal(IDirectedProtocolMessage request) { HttpWebRequest webRequest = this.CreateHttpRequest(request); IDictionary <string, string> responseFields; using (DirectWebResponse response = this.GetDirectResponse(webRequest)) { if (response.ResponseStream == null) { return(null); } responseFields = this.ReadFromResponseInternal(response); } IDirectResponseProtocolMessage responseMessage = this.MessageFactory.GetNewResponseMessage(request, responseFields); if (responseMessage == null) { return(null); } var responseSerializer = MessageSerializer.Get(responseMessage.GetType()); responseSerializer.Deserialize(responseFields, responseMessage); return(responseMessage); }
/// <summary> /// Gets the protocol message that may be in the given HTTP response. /// </summary> /// <param name="response">The response that is anticipated to contain an protocol message.</param> /// <returns>The deserialized message parts, if found. Null otherwise.</returns> /// <exception cref="ProtocolException">Thrown when the response is not valid.</exception> protected abstract IDictionary <string, string> ReadFromResponseInternal(DirectWebResponse response);