Skip to content

Instantly share code, notes, and snippets.

@cmatskas
Last active October 28, 2015 00:11
Show Gist options
  • Save cmatskas/1a1fad97f9c5bd6e4355 to your computer and use it in GitHub Desktop.
Save cmatskas/1a1fad97f9c5bd6e4355 to your computer and use it in GitHub Desktop.
Custom IEndpointBehavior
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
namespace APIServiceConsumer.Services
{
public class CustomInspectorBehavior : IEndpointBehavior
{
private readonly ClientMessageInspector clientMessageInspector = new ClientMessageInspector();
public string LastRequestXml
{
get { return clientMessageInspector.LastRequestXml; }
}
public string LastResponseXml
{
get { return clientMessageInspector.LastRequestXml; }
}
public void AddBindingParameters(
ServiceEndpoint endpoint,
System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, ClientRuntime clientRuntime)
{
clientRuntime.MessageInspectors.Add(clientMessageInspector);
}
}
}
@cmatskas
Copy link
Author

Fixed bad reference to the wrong class. Updated now to use the correct MessageInspector

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment