使用来自wsdl的webservice和asp.net的基本身份验证

时间:2015-01-22 10:00:01

标签: c# asp.net web-services wsdl

我有一个WSDL文件。我想从这个WSDL中使用webservice。我已经使用此WSDL添加了服务引用并创建了代理。我已经创建了调用我的服务方法所需的参数。实际上,webservice受基本身份验证保护。但在客户端代理中没有找到提供用户名和密码的选项。我怎么能调用webservice? 我想提供基本的身份验证凭据。

在没有提供凭据的情况下调用服务方法时出现以下错误。

 System.Net.WebException: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. 
---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure.

请帮帮我

1 个答案:

答案 0 :(得分:0)

试试这个:

client.ClientCredentials.UserName.UserName = "xxxxxx";
client.ClientCredentials.UserName.Password = "xxxxx";

https://msdn.microsoft.com/en-us/LIbrary/ms733775.aspx

相关问题