zoukankan      html  css  js  c++  java
  • WebServices调用AO的方法

    1 服务器端代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Services;
    using ESRI.ArcGIS.esriSystem;
    using ESRI.ArcGIS.DataSourcesGDB;
    using ESRI.ArcGIS.Geodatabase;
    using ESRI.ArcGIS.Geometry;
    using ESRI.ArcGIS.DataSourcesFile;

    [WebService(Namespace
    = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo
    = WsiProfiles.BasicProfile1_1)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class Service : System.Web.Services.WebService
    {
    public Service () {

    //如果使用设计的组件,请取消注释以下行
    //InitializeComponent();
    }

    [WebMethod]
    public string HelloWorld()
    {
    return "Hello World";
    }
    [WebMethod]
    public bool AddPointToFileGDB(double x, double y)
    {
    IAoInitialize aoInit
    = new AoInitializeClass();
    aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcServer);


    IWorkspaceFactory pWSF
    = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass() as IWorkspaceFactory;
    ESRI.ArcGIS.esriSystem.IPropertySet pPropertySet
    = new ESRI.ArcGIS.esriSystem.PropertySetClass();
    pPropertySet.SetProperty(
    "DATABASE", @"D:\数据\New File Geodatabase.gdb");
    IFeatureWorkspace pFW
    = pWSF.Open(pPropertySet, 0) as IFeatureWorkspace;

    IPoint pPoint
    = new PointClass();
    pPoint.X
    = x;
    pPoint.Y
    = y;

    IFeatureClass pFC
    = pFW.OpenFeatureClass("point");

    IFeature pF
    = pFC.CreateFeature();
    pF.Shape
    = pPoint;
    pF.Store();

    return true;
    }
    }

    2 客户端代码:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    
    public partial class _Default : System.Web.UI.Page 
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
            addpointserver.Service se = new addpointserver.Service();
            se.AddPointToFileGDBCompleted += new addpointserver.AddPointToFileGDBCompletedEventHandler(se_AddPointToFileGDBCompleted);
            se.AddPointToFileGDBAsync(double.Parse(TextBox1.Text),double.Parse( TextBox2.Text));
           
            
        }
    
        void se_AddPointToFileGDBCompleted(object sender, addpointserver.AddPointToFileGDBCompletedEventArgs e)
        {
            Response.Write("done!");
        }
    }
    

    3 注意事项:file gdb所在所在目录必须有 ASPNET角色和NETWorkService角色的读写权限,不然不能读写

    4 怎么才能在WinXP下,使得文件夹属性页有“安全”标签页呢?解决方法如下:

    1、 打开资源管理器
    2、 进入 工具——文件夹选项 菜单,切换到“查看”标签页
    3、 去掉“使用简单文件共享(推荐)”选项
  • 相关阅读:
    Django RequestContext用法
    【Django】Django命令(Manager.py)
    Django:快速搭建简单的Blog
    win7下安装Ubuntukylin-14.04双系统
    activity生命周期
    Activity(三)
    BZOJ 3944 Sum 解题报告
    BZOJ 3901 棋盘游戏 解题报告
    web框架之socket
    新式类__new__()方法
  • 原文地址:https://www.cnblogs.com/zhangjun1130/p/1954353.html
Copyright © 2011-2022 走看看