140 likes | 156 Views
Learn how to create a Web Service using .vb and .asmx files in ASP.NET. Follow the WebService directive to begin. Create a Web Service to calculate the area of a rectangle and test it. Utilize XML results and call the service using Windows Forms.
E N D
.vb檔案 Web Service區塊
.asmx檔案 以 ASP.NET 指示詞 WebService為開頭
建立Web Service <WebMethod()> _ Public Function area(ByVal length As String, ByVal width As String) As Integer Dim x, y As Integer x = Convert.ToInt32(length) y = Convert.ToInt32(width) Return x * y End Function 計算方形面積
呼叫使用Web Service 建立callWS專案
呼叫使用Web Service Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim myService As myws.Service = New myws.Service Dim z As Integer z = myService.area(TextBox1.Text, TextBox2.Text) TextBox3.Text = z.ToString() End Sub