添加SOAP头在.NET中的web服务SOAP、NET、web

2023-09-06 06:29:19 作者:风、扬起思念

我试图访​​问一个Web服务在我的.NET aplication,但web服务需要的凭据。 我如何添加SOAP头在.net中? web服务的NO-.net web服务。

I am trying to access to a webservice in my .net aplication, but the webservice needs credentials. how can i add the soap header in .net? the webservice in a NO-.net webservice.

推荐答案

可以做这样的事?

using (var service = new YourWebService())
{
    service.PreAuthenticate = true;
    service.UseDefaultCredentials = false;
    service.Credentials = new NetworkCredential(UserName, Password);
    var response = service.SomeMethod();
}