, WCF . WCF SOAP WS-Security (.. wsHttpBinding, ). web.config :
<bindings>
<wsHttpBinding>
<binding name="myBindingName">
<security mode="Message">
<transport clientCredentialType="None" />
<message clientCredentialType="UserName" />
</security>
:
<behaviors>
<serviceBehaviors>
<behavior name="myBehaviorName">
<serviceCredentials>
<userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="NameSpaceName.Class,AssemblyName" />
</serviceCredentials>
, , UserNamePasswordValidator ( System.IdentityModel.dll System.IdentityModel.Selectors) Validate:
public class MyValidator : UserNamePasswordValidator {
public override void Validate(string userName, string password) {
}
}
ASP.Net WCF ClientCredential , :
MyAPIClient client = new MyAPIClient();
client.ClientCredentials.UserName.UserName = theUsername;
client.ClientCredentials.UserName.Password = thePassword;
try {
client.Open();
client.DoSomething();
client.Close();
} catch (Exception ex) {
}
, , , behaviorConfiguration bindingConfiguration.