打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
【转】用VB调用Webservice
用VB调用Webservice

关键字:VB,WebService,C#,调试环境:vb6+sp5 , Vs.net 2005 , SOAP Toolkit 3.0 在VB中调用Webservice先要安装Soap Toolkit,可以到微软的网站上下载,下载地址为:http://www.microsoft.com/downloads/details.aspx?familyid=BA611554-5943-444C-B53C-C0A450B7013C&displaylang=en

1 首先用Vs.net建立WebService工程,添加以下调试代码

    [WebMethod]
    public string HelloWorld() {
        return "Hello World";
    }    [WebMethod]
    public int Add(int x,int y)
    {
        return x + y;
    }

2 新建VB工程,添加对soap toolkit的引用(Microsoft Soap Type Library 3.0)

3 在VB中添加以下代码:

Private Sub Command1_Click()
    Dim soapClient As New SoapClient30
    Dim text As String


    '注:此为本地的WebService地址,实际应用中会有不同

    soapClient.MSSoapInit "http://localhost:2239/DemoWebService/Service.asmx?WSDL"


    text = soapClient.HelloWorld '此处直接写服务端方法名
    MsgBox text
   
    Dim total As Integer
   
    total = soapClient.Add(2, 3)
   
    MsgBox total
End Sub

【转自】http://www.yuanma.org/data/2006/0619/article_857.htm

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
xml webservice完全实例解析(二)
Web Service 实例
delphi 调用 C#写的webservice
使?用?C?#?创?建?w?e?b?s?e?r?v?i?c?e?及?三?种?调?用?方?式
vb RegExp的Test方法
VB 获取字符串的字节长度
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服