Hi folks,
I'm creating a wrapper class (wrapper.dll) for some webservices.
One webservice need basic authentication.
Binding configuration is made in the code, not in app.config.
How can I pass the credentials to the custom binding?
Thanks.
Andy
What I have tried:
internal static CustomBinding BindingSoap12SslBasicAuthentication
{
get
{
var binding = new CustomBinding()
{
ReceiveTimeout = new TimeSpan(0, 0, 3, 0, 0),
SendTimeout = new TimeSpan(0, 0, 2, 0, 0),
};
binding.Elements.Add(new TextMessageEncodingBindingElement
{
MessageVersion = MessageVersion.Soap12,
});
binding.Elements.Add(new HttpsTransportBindingElement
{
MaxReceivedMessageSize = 50000000,
TransferMode = System.ServiceModel.TransferMode.Streamed,
AuthenticationScheme=System.Net.AuthenticationSchemes.Basic
});
binding.Elements.Add(new Credentials
{
user = "MyUser",
password = "MyPassword"
});
return binding;
}
}