callwsform.vb
来自「清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码」· VB 代码 · 共 28 行
VB
28 行
Imports System.Net
Public Class CallWSForm
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
'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 BasicAuthService.Service = New BasicAuthService.Service()
ws.Url = Me.WebServiceURL
' Create a NetworkCredential object with the username
' and password as entered in the Textbox controls
Dim creds As NetworkCredential = New NetworkCredential(UsernameTextBox.Text, PasswordTextBox.Text)
' Use this NetworkCredential object with the Web service proxy
ws.Credentials = creds
Try
ResponseLabel.Text = ws.HelloWorld()
Catch ex As Exception
ResponseLabel.Text = ex.Message
End Try
End Sub
End Class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?