add soap inspector

This commit is contained in:
Chika 2021-04-15 18:27:05 +03:00
parent ebc973093e
commit d60b6997de
4 changed files with 61 additions and 1 deletions

View File

@ -5,6 +5,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="System.ServiceModel.Duplex" Version="4.4.*" />
<PackageReference Include="System.ServiceModel.Http" Version="4.4.*" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="4.4.*" />
@ -15,4 +16,8 @@
<WCFMetadata Include="Connected Services" />
</ItemGroup>
<ItemGroup>
<Folder Include="Inspector" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,35 @@
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace ELT.Client.Inspector
{
public class InspectorBehavior : IEndpointBehavior
{
public MyMessageInspector myMessageInspector;
public InspectorBehavior() { }
public InspectorBehavior(MyMessageInspector myMessageInspector)
{
this.myMessageInspector = myMessageInspector;
}
public void AddBindingParameters(ServiceEndpoint endpoint, BindingParameterCollection bindingParameters)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.ClientMessageInspectors.Add(this.myMessageInspector);
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
}
}

View File

@ -0,0 +1,20 @@
using System.ServiceModel;
using System.ServiceModel.Dispatcher;
namespace ELT.Client.Inspector
{
public class MyMessageInspector : IClientMessageInspector
{
public string body;
public void AfterReceiveReply(ref System.ServiceModel.Channels.Message reply, object correlationState)
{
}
public object BeforeSendRequest(ref System.ServiceModel.Channels.Message request, IClientChannel channel)
{
body = request.ToString();
return null;
}
}
}

View File

@ -10,7 +10,7 @@ namespace ELT.Client.Managers.Insurance
{
public class KaskoManager : InsuranceManager<CalculateKaskoRequest, KASKOCalculationResult>
{
private readonly EltSoap _eltKaskoSoap;
private readonly EltSoapClient _eltKaskoSoap;
public KaskoManager()
{