Skip to content

Instantly share code, notes, and snippets.

@yaronn
Created September 26, 2015 03:28
Show Gist options
  • Save yaronn/73baedc9624256c69c57 to your computer and use it in GitHub Desktop.
Save yaronn/73baedc9624256c69c57 to your computer and use it in GitHub Desktop.
//disable wcf signature body header part
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Description;
using System.ServiceModel.Security;
using System.Text;
namespace ConsoleApplication309
{
public class B : IEndpointBehavior
{
#region IEndpointBehavior Members
public void AddBindingParameters(ServiceEndpoint endpoint, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
{
MessagePartSpecification m = new MessagePartSpecification();
m.IsBodyIncluded = true;
var c = bindingParameters.Remove<ChannelProtectionRequirements>();
var c1 = new ChannelProtectionRequirements();
c1.IncomingSignatureParts.AddParts(m, "*");
MessagePartSpecification m1 = new MessagePartSpecification();
m.IsBodyIncluded = false;
c1.IncomingEncryptionParts.AddParts(m1, "*");
bindingParameters.Add(c1);
}
public void ApplyClientBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.ClientRuntime clientRuntime)
{
}
public void ApplyDispatchBehavior(ServiceEndpoint endpoint, System.ServiceModel.Dispatcher.EndpointDispatcher endpointDispatcher)
{
}
public void Validate(ServiceEndpoint endpoint)
{
}
#endregion
}
class Program
{
static void Main(string[] args)
{
ServiceReference1.SimpleServiceSoapClient c= new ConsoleApplication309.ServiceReference1.SimpleServiceSoapClient();
c.ChannelFactory.Endpoint.Behaviors.Add(new B());
//c.ChannelFactory.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;
c.EchoString("1");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment