SOAP-ENV:Client.authenticationErrorinvalid username or password
Protected Sub ClickButton_Test() Dim resultdata As String = "" Dim UserName As String = "Username@Location" Dim Password As String = "difficultpassword" Dim urltarget As String = "https://SpecialSite" Dim s As HttpWebRequest Dim enc As UTF8Encoding Dim postdatabytes As Byte() s = HttpWebRequest.Create(urltarget) enc = New System.Text.UTF8Encoding() Dim filecontent As String = "C:\TestData\Put_PO_XML.txt" Dim value As String = File.ReadAllText(filecontent) postdatabytes = enc.GetBytes(value) s.UseDefaultCredentials = False Dim byt As Byte() = System.Text.Encoding.UTF8.GetBytes(Password) Dim PasswordText As String = Convert.ToBase64String(byt) s.Credentials = New System.Net.NetworkCredential(UserName, PasswordText) s.Method = "POST" s.AllowAutoRedirect = True s.ContentType = "text/xml;charset=UTF-8" s.ContentLength = postdatabytes.Length s.KeepAlive = True s.ProtocolVersion = HttpVersion.Version11 s.Host = "services.website.com" s.UserAgent = "Apache-HttpClient/4.1.1 (java 1.5)" s.AuthenticationLevel = Net.Security.AuthenticationLevel.None Using stream = s.GetRequestStream() stream.Write(postdatabytes, 0, postdatabytes.Length) End Using Try Dim result = s.GetResponse() Using stream As Stream = result.GetResponseStream() Dim reader As New StreamReader(stream, Encoding.UTF8) resultdata = reader.ReadToEnd() End Using Catch ex As WebException resultdata = New StreamReader(ex.Response.GetResponseStream()).ReadToEnd() End Try Me.APIResult.Text = resultdata End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)