servicestack,Authentication,Soap,servicestack" /> servicestack,Authentication,Soap,servicestack" />

Authentication 如何使用servicestack调用soap web服务来调用用户身份验证以确定应该执行的id服务?

Authentication 如何使用servicestack调用soap web服务来调用用户身份验证以确定应该执行的id服务?,authentication,soap,servicestack,Authentication,Soap,servicestack,我是servicestack的新手。我需要使用实现servicestack的用户ID和密码对soap请求进行身份验证 我已经创建了一个自定义CredentialAuthProvider,它覆盖了此方法: public override bool TryAuthenticate(IServiceBase authService, string userName, string password) 并补充说 Plugins.Add(new AuthFeature(() => new Auth

我是servicestack的新手。我需要使用实现servicestack的用户ID和密码对soap请求进行身份验证

我已经创建了一个自定义CredentialAuthProvider,它覆盖了此方法:

public override bool TryAuthenticate(IServiceBase authService,
string userName, string password)
并补充说

Plugins.Add(new AuthFeature(() => new AuthUserSession(),
               new IAuthProvider[] {
                    new SFCredentialsAuthProvider(),
               } 
to config in AppHost.
我的问题是如何从soapweb服务调用中验证用户

示例显示如下内容:

var client = new JsonServiceClient(BaseUrl);

var authResponse = client.Post(new Authenticate {
    provider = CredentialsAuthProvider.Name, //= credentials
    UserName = "test@gmail.com",
    Password = "p@55w0rd",
    RememberMe = true,
});
但是,如果请求经过身份验证,我将只执行服务,那么这个BaseUrl应该是什么呢


我不知道在servicestack上执行soap服务时如何调用身份验证。请提供帮助。

基本URL应该是ServiceStack服务所在的基本URL,例如,对于本地IIS Express开发服务器,它通常采用
http://localhost:{PortNumber}
当您点击
F5
运行应用程序时,将加载该程序

不确定您的问题与SOAP有什么关系,因为您使用的是调用JSON HTTP API的
JsonServiceClient
。对于SOAP,您通常会在ServiceStack
/wsdl
端点添加一个WCF服务引用,以从wsdl定义生成一个客户端代理,用于访问您的服务


但是当您不需要使用SOAP,只需使用示例中所示的
JsonServiceClient
时。

我已经很久没有用BasicAuthProvider解决这个问题了。示例代码如下:

public override bool TryAuthenticate(IServiceBase authService,
        string userName, string password)
    {
        var httpReq = authService.Request;
        var basicAuth = httpReq.GetBasicAuthUserAndPassword();
        if (basicAuth == null)
            throw HttpError.Unauthorized(ErrorMessages.InvalidBasicAuthCredentials.Localize(authService.Request));

        var userid = basicAuth.Value.Key;
        var pwd = basicAuth.Value.Value;
//使用用户ID和密码进行身份验证


}

只想在这里发布它,以防它会帮助其他刚加入servicestack进行身份验证的人