/// <summary> /// Sends a request message. /// </summary> /// <typeparam name="TInput">The type of the request.</typeparam> /// <typeparam name="TOutput">The type of the response.</typeparam> /// <param name="input">The request.</param> /// <param name="token">The token that can be used to cancel the operation.</param> /// <returns>The response.</returns> /// <exception cref="InvalidOperationException">Attempts to send message to local or unavailable endpoint.</exception> /// <exception cref="OperationCanceledException">The operation has been canceled.</exception> public Task <TOutput> SendMessageAsync <TInput, TOutput>(TInput input, CancellationToken token = default) { Task <TOutput> result; try { result = channel.SendMessageAsync(CreateMessage <TInput>(input), GetMessageReader <TOutput>(), token); } catch (Exception e) { result = Task.FromException <TOutput>(e); } return(result); }