SoapUI身份验证与C#

时间:2015-01-15 23:33:39

标签: c# .net web-services soapui basic-authentication

我有一个使用以下凭据在SoapUI中正常运行的Web服务:

Authentication: Basic
Username: testUser
Password: testPassword
Domain: IPaddress

当我尝试使用此代码在我的C#应用​​程序中使用它时

soapWS.Service soapWS = new soapWS.Service();
soapWS.Credentials = new NetworkCredential("testUser", "testPassword", "IPaddress");

我收到以下错误

  

异常startSession:用户IPaddress \ testUser的FailedLoginException;嵌套异常是:

我对SoapUI进行了更多的研究,而SoapUI中的域是

Domain : The domain to use if the request requires NTLM authentication)

我试过

soapWS.Credentials = new NetworkCredential("testUser@IPaddress", "testPassword");

哪个也不起作用。

2 个答案:

答案 0 :(得分:0)

NetworkCredential构造函数的最后一个参数应该是域名和IP地址。 以下行

soapWS.Credentials = new NetworkCredential("testUser", "testPassword", "IPaddress");

应该是

soapWS.Credentials = new NetworkCredential("testUser", "testPassword", "your domain name");

答案 1 :(得分:0)

我所要做的只是放弃" IPaddress"在我的对象中。

soapWS.Credentials = new NetworkCredential("testUser", "testPassword");