Adding Authorization Header to Web Reference

前端 未结 3 934

I\'m attempting to make requests to a client\'s web service (I don\'t know the underlying platform at the client). I\'ve consumed the client\'s WSDL in Visual Studio 2010 using

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 11:51

    I am writing this for whom that has this problem now. As in preceding answers mentioned inheritance hierarchy goes up to WebClientProtocol class, this class has a ICredentials property, simply set this property by a NetworkCredential instance as below:

    YourServis.Credentials = new NetworkCredential("UserName", "Password", "Domain");
    

    I think taht is simplest way without changing Reference.cs or adding headers.

提交回复
热议问题