Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF和自定义Soap身份验证_Wcf_Authentication_Soap - Fatal编程技术网

WCF和自定义Soap身份验证

WCF和自定义Soap身份验证,wcf,authentication,soap,Wcf,Authentication,Soap,我正在开发一个服务器应用程序,使用WCF为客户端公开WebService端点。我想通过一个简单的自定义提供者实现身份验证,该提供者将使用通过SOAP头传递的用户名和密码。我知道如何设置要在客户端发送的用户名和密码,我只想知道如何从服务器端的SOAP头中提取用户名和密码。非常感谢您的帮助。您需要在服务行为中指定用户名和密码验证器 <behavior name="MyServiceBehavior"> <serviceCredentials> <userNa

我正在开发一个服务器应用程序,使用WCF为客户端公开WebService端点。我想通过一个简单的自定义提供者实现身份验证,该提供者将使用通过SOAP头传递的用户名和密码。我知道如何设置要在客户端发送的用户名和密码,我只想知道如何从服务器端的SOAP头中提取用户名和密码。非常感谢您的帮助。

您需要在服务行为中指定用户名和密码验证器

<behavior name="MyServiceBehavior">
  <serviceCredentials>
    <userNameAuthentication userNamePasswordValidationMode="Custom"
      customUserNamePasswordValidatorType="MyNamespace.MyUserNamePasswordValidator, MyDll" />
  </serviceCredentials>
</behavior>

我遵循您的提示,但a无法调用Validate方法。我需要使用basicHttpBinding发送用户名和密码,而不需要HTTPS,也不需要在服务器上安装证书。
public class MyUserNamePasswordValidator : UserNamePasswordValidator
{
    public override void Validate( string userName, string password )
    {
        // valid your password here 
    }
}