📄 customsoapheaderform.vb
字号:
Imports CustomSOAPHeaders.CustomSoapHeadersService
Public Class CustomSOAPHeaderForm
Private ReadOnly WebServiceURL As String = "http://myServer/BasicAuthService/Service.asmx"
Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
invokeIt(Nothing)
End Sub
Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
Dim hdr As AuthHeader = New AuthHeader()
hdr.Username = "andy"
hdr.Password = "WRONG"
invokeIt(hdr)
End Sub
Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
Dim hdr As AuthHeader = New AuthHeader()
hdr.Username = "andy"
hdr.Password = "P455w0rd"
invokeIt(hdr)
End Sub
Private Sub invokeIt(ByVal hdr As AuthHeader)
'Check that the Web Service URL is updated
System.Diagnostics.Debug.Assert(Not Me.WebServiceURL.IndexOf("myServer") = -1, "You must change the value of the WebServiceURL field to the URL where you have installed the BasicAuthService Web Service")
Dim ws As SOAPHeaderService = New SOAPHeaderService()
ws.Url = Me.WebServiceURL
ws.AuthHeaderValue = hdr
Try
Dim response As Boolean = ws.Authenticate()
label1.Text = "Web Service returned: " + response.ToString()
Catch ex As System.Web.Services.Protocols.SoapException
label1.Text = "SOAP exception, message: " + ex.Message
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -