首页 > 编程 > .NET > 正文

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

2024-07-10 13:01:48
字体:
来源:转载
供稿:网友

商业源码热门下载www.html.org.cn

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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表