CTOCIO IT专家网

天极传媒 比特网 | 天极网 | IT专家网 | IT商网 | 52PK游戏网 | 手机天极 | IT分众 |
IT专家网搜索

您现在的位置: IT专家网 > Web服务子站 > 技巧

Web服务系列教学-如何调用WebService(3)

作者: ,  出处:5ivb, 责任编辑: 叶江, 
2005-09-14 14:07
  在本部分,您将学习到如何使用C#;javascript;vb.net;vb6.0,vbscript调用WebService。

4. 5使用C#调用

无需下载任何组件
Visual项目新建 windows应用程序。C#项目

在解决方案资源管理器中添加web引用,输入wsdl文件所在地址。

将web引用改名.
yundan.(service_name)即可引用
*需引用System.web.services*

例程:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
namespace csharp
{
        public class Form1 : System.Windows.Forms.Form
        {
            private System.Windows.Forms.Label label1;
            private System.Windows.Forms.TextBox textBox1;
            private System.ComponentModel.Container components = null;
            public Form1()
            {
                InitializeComponent();
            }
            protected override void Dispose( bool disposing )
            {
                if( disposing )
                {
                    if (components != null)
                    {
                        components.Dispose();
                    }
                }
                base.Dispose( disposing );
            }
            #region Windows Form Designer generated code
            private void InitializeComponent()
            {
                this.label1 = new System.Windows.Forms.Label();
                this.textBox1 = new System.Windows.Forms.TextBox();
                this.SuspendLayout();
                this.label1.AutoSize = true;
                this.label1.Location = new System.Drawing.Point(88, 48);
                this.label1.Name = "label1";
                this.label1.Size = new System.Drawing.Size(91, 14);
                this.label1.TabIndex = 0;
                this.label1.Text = "Webservice演示";
                this.textBox1.Location = new System.Drawing.Point(88, 128);
                this.textBox1.Name = "textBox1";
                this.textBox1.TabIndex = 1;
                this.textBox1.Text = "textBox1";
                this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
                this.ClientSize = new System.Drawing.Size(292, 273);
                this.Controls.AddRange(new System.Windows.Forms.Control[]
{
                this.textBox1,
                this.label1
});
                this.Name = "Form1";
                this.Text = "C#Webservie演示";
                this.Load += new System.EventHandler(this.Form1_Load);
                this.ResumeLayout(false);
            }
            #endregion
            [STAThread]
            static void Main()
            {
                Application.Run(new Form1());
            }

            private void Form1_Load(object sender, System.EventArgs e)
            {
                int str;
                你的web引用的名字.Service1 cc=new 你的web引用的名字.Service1();
                str=cc.test(123,324);
                textBox1.Text=str.ToString();
            }
        }
}

共3页。 1 2 3 :
  • 本文关键词:

网友评论

笔名 
请您注意:遵守国家有关法律、法规,尊重网上道德,承担一切因您的行为而直接或间接引起的法律责任。    IT专家网友拥有管理笔名和留言的一切权利。
  • 周排行榜
  • 月排行榜

邮件订阅

       

该文章的读者还阅读了

天极服务 | 关于我们 | 网站律师 | 加入我们 | 联系我们 | 广告业务 | 友情链接 | 我要挑错