[英]Incorrect username and password with Basic Authentication
I am new to SOAPUI.我是 SOAPUI 的新手。 So far;迄今为止; I have created the default WCF project in Visual Studio;我已经在 Visual Studio 中创建了默认的 WCF 项目; published it to IIS and then tested it in SOAPUI.将其发布到 IIS,然后在 SOAPUI 中对其进行测试。 This worked as expected.这按预期工作。
I am now trying to test a simple WCF Service, which uses Basic Authentication.我现在正在尝试测试一个使用基本身份验证的简单 WCF 服务。 I can test this WCF Service (with Basic Authentication) in a C# program as follows (this works as expected):我可以在 C# 程序中测试此 WCF 服务(使用基本身份验证),如下所示(这按预期工作):
public Form1()
{
InitializeComponent();
ServiceReference1.Service1Client s1 = new ServiceReference1.Service1Client();
s1.ClientCredentials.UserName.UserName = "testuser";
s1.ClientCredentials.UserName.Password = "testpassword";
string str = s1.GetData(1);
}
I am now trying to test this in SOAPUI.我现在正尝试在 SOAPUI 中对此进行测试。 I have the following setup:我有以下设置:
Note I have already right clicked and selected: Add WSS Username Token and selected: PasswordText.注意我已经右键单击并选择:添加 WSS 用户名令牌并选择:密码文本。
I have also gone to: File/Preferences/HTTP Settings and selected: "adds authentication information to outgoing request".我还去了:文件/首选项/HTTP 设置并选择:“向传出请求添加身份验证信息”。
What is the problem?问题是什么?
I have spent a long time trying to get the Auth window to work.我花了很长时间试图让 Auth 窗口工作。
Instead I have done this, which works:相反,我这样做了,它有效:
1.In the Request window, select the “Headers” tab on the bottom left. 1.在“请求”窗口中,选择左下角的“标头”选项卡。
2.Click the “+” button to add a header. 2.单击“+”按钮添加标题。 The name of the header must be “Authorization.”标题的名称必须是“授权”。 Click OK.单击确定。
3.In the value box, enter the word “Basic” plus the base64-encoded username:password. 3.在值框中,输入单词“Basic”加上 base64 编码的用户名:密码。 Use a base 64 encoder/decoder tool to create the base64 user:password string.使用 base 64 编码器/解码器工具创建 base64 用户:密码字符串。 For example, the Base64 version of “testuser:testpwd” is “dGVzdHVzZXI6dGVzdHB3ZA==” so the Value for the header would be Basic dGVzdHVzZXI6dGVzdHB3ZA==例如,“testuser:testpwd”的 Base64 版本是“dGVzdHVzZXI6dGVzdHB3ZA==”,因此标头的值将是 Basic dGVzdHVzZXI6dGVzdHB3ZA==
I found the instructions here: http://www.ibm.com/support/knowledgecenter/SSPVUA_10.0.0/com.ibm.mdshs.esoatoolkit.doc/topics/t_esoatoolkit_createsoapUIhttpbasicauth.html我在这里找到了说明:http: //www.ibm.com/support/knowledgecenter/SSPVUA_10.0.0/com.ibm.mdshs.esoatoolkit.doc/topics/t_esoatoolkit_createsoapUIhttpbasicauth.html
Here is a base64 encoder I used: https://www.base64encode.org/这是我使用的 base64 编码器: https ://www.base64encode.org/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.