50 lines
1.3 KiB
C#
50 lines
1.3 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.ServiceModel;
|
|
using System.ServiceModel.Channels;
|
|
|
|
|
|
/*
|
|
* Want more WCF tips?
|
|
* Visit http://webservices20.blogspot.com/
|
|
*/
|
|
|
|
|
|
namespace WebServices20.BindingExtenions
|
|
{
|
|
public class ClearUsernameBinding : CustomBinding
|
|
{
|
|
private MessageVersion messageVersion = MessageVersion.None;
|
|
|
|
public void SetMessageVersion(MessageVersion value)
|
|
{
|
|
this.messageVersion = value;
|
|
}
|
|
|
|
public override BindingElementCollection CreateBindingElements()
|
|
{
|
|
|
|
TransportSecurityBindingElement tsbe = SecurityBindingElement.CreateUserNameOverTransportBindingElement();
|
|
var res = new BindingElementCollection();
|
|
res.Add(new TextMessageEncodingBindingElement() { MessageVersion = this.messageVersion});
|
|
tsbe.IncludeTimestamp = false;
|
|
res.Add(tsbe);
|
|
AutoSecuredHttpTransportElement ashp = new AutoSecuredHttpTransportElement();
|
|
ashp.MaxReceivedMessageSize = Int32.MaxValue; // Why not?
|
|
res.Add(ashp);
|
|
|
|
return res;
|
|
|
|
|
|
}
|
|
|
|
public override string Scheme
|
|
{
|
|
get
|
|
{
|
|
return "http";
|
|
}
|
|
}
|
|
}
|
|
}
|