37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.ServiceModel;
|
|
using System.ServiceModel.Channels;
|
|
using System.ServiceModel.Dispatcher;
|
|
using System.Text;
|
|
|
|
namespace Taloyhtio.GeneralApi.IntegrationUtility.Infrastructure
|
|
{
|
|
public class PoxClientMessageInspector : IClientMessageInspector
|
|
{
|
|
public object BeforeSendRequest(ref Message request, IClientChannel channel)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
public void AfterReceiveReply(ref Message reply, object correlationState)
|
|
{
|
|
if (reply != null)
|
|
{
|
|
var property = (HttpResponseMessageProperty)reply.Properties[HttpResponseMessageProperty.Name];
|
|
if (property != null)
|
|
{
|
|
string error = property.Headers[GeneralApi.Common.Constants.HttpHeaders.Error];
|
|
if (!string.IsNullOrEmpty(error))
|
|
{
|
|
error = Encoding.UTF8.GetString(Convert.FromBase64String(error));
|
|
throw new CommunicationException(error);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|