C# 添加服务引用。

1,服务引用给的实例(需要一个网址连接)

http://192.168.17.131:12170/amtiot.gis.WCF/SpatialAnalysis.svc  (类似于这样的一个网址)

在网络里面打开后的截图:

2,在vs中新建一个c#工程,添加服务引用,将地址粘贴如下图点击前往后即可使用(命名空间可以根据自己的需求更改)

添加完成后:

3,使用代码中只有带标号的四句话是添加的。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using tt.ServiceReference1;                              //1

namespace tt
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            SpatialAnalysisClient client = new SpatialAnalysisClient();                //2
            ServiceReference1.BoundaryInfo result = client.GetBoundaryWithSensorWidth("S535100031", "2015-06-11 13:00:00", "2015-06-11 13:35:00", false); //3
            client.Close();  //4

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());
        }
    }
}

 

posted @ 2015-07-21 17:14  lwn6  阅读(7450)  评论(1编辑  收藏  举报
什么是幸福?天天在做自己想做的事情,家人、同事、朋友、客户、网友都和和睦睦,身体健康、钱包鼓鼓、女朋友天天开心、生活无忧无虑就是最大的幸福