webservice引用

 1  class VidyoPortalUserServiceWithAuthentication : VidyoPortalUserService
 2     {
 3         String _username;
 4         String _password;
 5         public VidyoPortalUserServiceWithAuthentication(String username, String password)
 6         {
 7             _username = username;
 8             _password = password;
 9         }
10         protected override WebRequest GetWebRequest(Uri uri)
11         {
12             WebRequest wr = base.GetWebRequest(uri);
13             wr.Headers.Add("Authorization", "Basic " +
14                 Convert.ToBase64String(Encoding.ASCII.GetBytes(_username + ":" + _password)));
15             return wr;
16         }
17     }
18 
19 VidyoPortalUserServiceWithAuthentication vpus = new VidyoPortalUserServiceWithAuthentication(this.tbxID.Text, this.tbxPwd.Text);
20 
21 
22                 HttpWebRequest request = (HttpWebRequest)WebRequest.Create(RequestString);
23 
24                 request.AllowAutoRedirect = false;
25                 request.Method = "GET";
26                 // Get Found (302) response.
27                 HttpWebResponse response = (HttpWebResponse)request.GetResponse();

 

posted @ 2017-06-01 14:47  dyfisgod  阅读(179)  评论(0编辑  收藏  举报