webservice系列教学(8)-如何调用webservice(vb.net)

本文介绍如何使用VB.NET创建Windows应用程序并调用WebService。具体步骤包括新建项目、添加Web引用及调用WebService方法。示例代码展示了如何在Form加载时通过调用WebService获取数据。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

4.7使用vb.net调用
无需下载任何组件
新建项目Visual Basic项目windows应用程序。
在解决方案资源管理器中添加web引用,输入wsdl文件所在地址。
将web引用改名为yundan.
yundan.(service_name)即可引用
*需引用System.web.services*
例程:
    Public Class Form1
        Inherits System.Windows.Forms.Form
#Region " Windows 窗体设计器生成的代码 "
    Public Sub New()
        MyBase.New()
        InitializeComponent()
    End Sub
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub
    Private components As System.ComponentModel.IContainer
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.TextBox1 = New System.Windows.Forms.TextBox()
        Me.SuspendLayout()
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(96, 40)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(91, 14)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "Webservice演示"
        Me.TextBox1.Location = New System.Drawing.Point(88, 144)
        Me.TextBox1.Name = "TextBox1"
        Me.TextBox1.TabIndex = 1
        Me.TextBox1.Text = "TextBox1"
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.TextBox1, Me.Label1})
        Me.Name = "Form1"
        Me.Text = "VB.net webserive演示"
        Me.ResumeLayout(False)
    End Sub
#End Region
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim cc As yundan.Service1 = New yundan.Service1()
        TextBox1.Text = cc.test(12, 123)
    End Sub
End Class

转载于:https://www.cnblogs.com/savageworld/archive/2006/08/16/478865.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值