{"id":35,"date":"2009-06-13T17:23:00","date_gmt":"2009-06-13T17:23:00","guid":{"rendered":"http:\/\/blog.newnaw.com\/?p=35"},"modified":"2009-06-13T17:23:00","modified_gmt":"2009-06-13T17:23:00","slug":"arcgis-api-for-silverlight%e5%bc%80%e5%8f%91%e5%85%a5%e9%97%a8%e5%a4%96%e4%bc%a0%ef%bc%9a%e5%9c%a8%e7%a8%8b%e5%ba%8f%e4%b8%ad%e8%b0%83%e7%94%a8ao","status":"publish","type":"post","link":"https:\/\/blog.newnaw.com\/?p=35","title":{"rendered":"ArcGIS API for Silverlight\u5f00\u53d1\u5165\u95e8\u5916\u4f20\uff1a\u5728\u7a0b\u5e8f\u4e2d\u8c03\u7528AO"},"content":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Silverlight API\u7684\u5f00\u53d1\u5165\u95e8\u7cfb\u5217\u7684\u6587\u7ae0\u4e0a\u56de\u5df2\u7ecf\u7ed3\u675f\uff0c\u4f46\u5176\u5b9e\u80fd\u8bb2\u7684\u4e1c\u897f\u8fd8\u6709\u5f88\u591a\uff0c\u5b9e\u5728\u4e0d\u80fd\u9762\u9762\u4ff1\u5230\u3002\u8fd9\u6b21\u518d\u8865\u5145\u4e00\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u529f\u80fd\uff0c\u5c31\u662f\u5728Silverlight API\u7a0b\u5e8f\u4e2d\u8c03\u7528ArcObjects\uff0c\u6765\u5b8c\u6210\u4e00\u4e9b\u590d\u6742\u7684geoprocess\u529f\u80fd\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADF\u4e4b\u6240\u4ee5\u5f3a\u5927\uff0c\u9664\u4e86\u5176\u672c\u8eab\u7684\u7c7b\u5e93\u5916\uff0c\u5b83\u8fd8\u80fd\u5728\u670d\u52a1\u5668\u7aef\u8c03\u7528AO\uff0c\u6765\u5b8c\u6210\u6bd4\u5982\u5728\u7ebf\u7f16\u8f91\u6216\u8005Geoemtry\u7684\u5904\u7406\u5de5\u4f5c\uff1b\u800cESRI\u5b98\u65b9\u7684\u8bf4\u6cd5\uff0c\u5efa\u7acb\u5728REST\u670d\u52a1\u57fa\u7840\u4e0a\u7684\u7a0b\u5e8f\u76ee\u524d\u90fd\u4e0d\u5177\u5907\u5728\u7ebf\u7f16\u8f91\u7684\u529f\u80fd\uff08\u56e0\u4e3a\u8981\u4e0e\u670d\u52a1\u5668\u7aef\u7684\u6570\u636e\u5e93\u6253\u4ea4\u9053\uff09\uff0c\u4f46\u4ed6\u4eec\u628a\u8fd9\u9879\u529f\u80fd\u4f5c\u4e3a\u65e5\u7a0b\uff0c\u63d0\u5230\u4e86\u7814\u53d1\u8ba1\u5212\u5185\u3002\u76ee\u524d\u800c\u8a00\uff0c\u8981\u5728Silverlight API\u4e2d\u5b8c\u6210\u6570\u636e\u7f16\u8f91\u5de5\u4f5c\uff0c\u4ed6\u4eec\u7684\u529d\u544a\u662f\uff0c\u201c\u5982\u679c\u4f60\u4e0d\u6015\u628a\u4f60\u7684\u53cc\u624b\u5f04\u810f\uff0c\u90a3\u5c31\u53bb\u505a\u5427\u201d\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8a00\u5f52\u3002AO\u672c\u8eab\u662fCOM\u7ec4\u4ef6\uff0c.NET\u662f\u5229\u7528COM Interop\u6280\u672f\u4e0e\u5176\u6253\u4ea4\u9053\u7684\uff0c\u8fd9\u663e\u7136\u662fSilverlight\u7684\u5ba2\u6237\u7aef\u73af\u5883\u529e\u4e0d\u5230\u7684\u3002\u8fd9\u5c31\u9700\u8981\u4e0e\u670d\u52a1\u5668\u7aef\u8fdb\u884c\u901a\u4fe1\u3002Silverlight\u4e0e\u670d\u52a1\u5668\u7aef\u901a\u4fe1\uff0c\u6700\u5e38\u7528\u7684\u662fWebClient\u7c7b\uff0c\u7a0d\u590d\u6742\u7684\u8fd8\u6709HttpWebRequest\u7c7b\uff0c\u800c\u4f20\u7edf\u7684ASP.NET Web Service\u4e0e\u66f4\u5f3a\u5927\u7684WCF\u5219\u4e3a\u8fdc\u7a0b\u8c03\u7528AO\u63d0\u4f9b\u4e86\u53ef\u80fd\u3002\u4e0b\u9762\u8fd8\u662f\u6765\u770b\u4e00\u4e2a\u5b9e\u4f8b\uff0c\u529f\u80fd\u662f\u5728\u7a0b\u5e8f\u4e2d\u5411\u6570\u636e\u5e93\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u70b9\uff0c\u4ee5Web Service\u4e3a\u4f8b\uff08\u5173\u4e8e\u5982\u4f55\u4f7f\u7528Web Service\u53ef\u4ee5\u67e5\u8d44\u6599\uff0c\u8fd9\u91cc\u4e0d\u505a\u8bb2\u89e3\uff09\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5728Silverlight\u6240\u5728\u7684ASP.NET\u5de5\u7a0b\u4e2d\u65b0\u5efa\u4e00\u4e2aASP.NET Web Service\uff0c\u6dfb\u52a0\u4e00\u4e2aWebMethod\uff0c\u5982\u4e0b\uff1a<br \/><code>public class WS_AOAddPoint : System.Web.Services.WebService<br \/>    {<\/p>\n<p>        [WebMethod]<br \/>        public string HelloWorld()<br \/>        {<br \/>            return \"Hello World\";<br \/>        }<\/p>\n<p>        [WebMethod]<br \/>        public bool AddPointToFileGDB(double x, double y)<br \/>        {<br \/>            IAoInitialize aoInit = new AoInitializeClass();<br \/>            aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);<\/p>\n<p>            IWorkspaceFactory pWSF = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass() as IWorkspaceFactory;<br \/>            ESRI.ArcGIS.esriSystem.IPropertySet pPropertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();<br \/>            pPropertySet.SetProperty(\"DATABASE\", @\"E:arcgisserveragsedit_simpleaddpointchina_airlines.gdb\");<br \/>            IFeatureWorkspace pFW = pWSF.Open(pPropertySet, 0) as IFeatureWorkspace;<\/p>\n<p>            IPoint pPoint = new PointClass();<br \/>            pPoint.X = x;<br \/>            pPoint.Y = y;<\/p>\n<p>            IFeatureClass pFC = pFW.OpenFeatureClass(\"\u7701\u4f1a\u57ce\u5e02\");<br \/>            IFeature pF = pFC.CreateFeature();<br \/>            pF.Shape = pPoint;<br \/>            pF.Store();<\/p>\n<p>            return true;<br \/>        }<br \/>    }<\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8be5\u65b9\u6cd5\u4f20\u5165\u4e24\u4e2adouble\u53c2\u6570\uff0c\u4f5c\u4e3a\u65b0\u5efa\u70b9\u7684\u5750\u6807\uff0c\u8fd9\u4e24\u4e2a\u53c2\u6570\u53ef\u5728\u5ba2\u6237\u7aef\u7684Draw_Complete\u4e8b\u4ef6\u4e2d\u83b7\u53d6\u3002\u4e3a\u8be5\u5de5\u7a0b\u8bbe\u7f6e\u4e00\u4e2a\u56fa\u5b9a\u7684\u7aef\u53e3\uff0c\u7136\u540e\u5728Silverlight\u7a0b\u5e8f\u4e2d\u6dfb\u52a0\u5bf9\u8be5Web Service\u7684\u5f15\u7528\u3002\u4e4b\u540e\u5728Page.xaml.cs\u4e2d\uff0c\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<br \/><code>private void Draw1_DrawComplete(object sender,DrawEventArgs args)<br \/>        {<br \/>            GraphicsLayer glayer = Map1.Layers[\"glayer\"] as GraphicsLayer;<br \/>            Graphic g = new Graphic()<br \/>            {<br \/>                Symbol = markerSymbol,<br \/>                Geometry = args.Geometry<br \/>            };<br \/>            glayer.Graphics.Add(g);<\/p>\n<p>            WS.WS_AOAddPointSoapClient client = new WS.WS_AOAddPointSoapClient();<br \/>            client.AddPointToFileGDBCompleted+=new EventHandler<ws.addpointtofilegdbcompletedeventargs>(client_AddPointToFileGDBCompleted);<br \/>            client.AddPointToFileGDBAsync((args.Geometry as ESRI.ArcGIS.Geometry.MapPoint).X, (args.Geometry as ESRI.ArcGIS.Geometry.MapPoint).Y);<br \/>        }<\/p>\n<p>        private void client_AddPointToFileGDBCompleted(object sender, WS.AddPointToFileGDBCompletedEventArgs args)<br \/>        {<br \/>            MessageBox.Show(args.Result.ToString());<br \/>        }<\/ws.addpointtofilegdbcompletedeventargs><\/code><br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u6700\u540e\u770b\u770b\u6548\u679c:<\/p>\n<div style=\"text-align: center;\"><a href=\"http:\/\/lh5.ggpht.com\/_DD8LUY9p6iU\/SjN9mqVHW9I\/AAAAAAAAAMM\/IavtB2cxaIw\/SL_AO_AddPoint1.jpg\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/lh5.ggpht.com\/_DD8LUY9p6iU\/SjN9mqVHW9I\/AAAAAAAAAMM\/IavtB2cxaIw\/SL_AO_AddPoint1.jpg\" width=\"298\" height=\"253\" \/><\/a><\/div>\n<p><\/p>\n<div style=\"text-align: center;\"><a href=\"http:\/\/lh5.ggpht.com\/_DD8LUY9p6iU\/SjN9mvE3gxI\/AAAAAAAAAMQ\/FOuLz1ADyUY\/SL_AO_AddPoint2.jpg\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/lh5.ggpht.com\/_DD8LUY9p6iU\/SjN9mvE3gxI\/AAAAAAAAAMQ\/FOuLz1ADyUY\/SL_AO_AddPoint2.jpg\" width=\"298\" height=\"253\" \/><\/a><\/div>\n<p><\/p>\n<div style=\"text-align: center;\"><a href=\"http:\/\/lh5.ggpht.com\/_DD8LUY9p6iU\/SjN9myKmSgI\/AAAAAAAAAMU\/d-i7t54kvg4\/SL_AO_AddPoint3.jpg\" target=\"_blank\"><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/lh5.ggpht.com\/_DD8LUY9p6iU\/SjN9myKmSgI\/AAAAAAAAAMU\/d-i7t54kvg4\/SL_AO_AddPoint3.jpg\" width=\"298\" height=\"253\" \/><\/a><\/div>\n<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u9700\u8981\u8865\u5145\u4e00\u4e0b\uff0c\u5728Web Service\u7684\u65b9\u6cd5\u4e2d\uff0c\u5982\u679c\u4e0d\u6dfb\u52a0AO\u521d\u59cb\u5316\u7684\u8bed\u53e5\uff0c\u4f1a\u62a5The remote server returned an error: NotFound\u7684\u9519\u8bef\uff1b\u800c\u8c03\u8bd5\u8be5Web Service\u7684\u65b9\u6cd5\uff0c\u8fd4\u56dehttp 500 \u9519\u8bef\uff1b\u5728ie\uff0c\u5c06\u9ad8\u7ea7\u91cc\u9762\u7684\u201c\u663e\u793a\u53cb\u597d\u9519\u8bef\u63d0\u793a\u201d\u52fe\u6389\uff0c\u8fd4\u56de\u771f\u6b63\u7684\u9519\u8bef\u662fSystem.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80040228\uff0c\u7531\u6b64\u65ad\u5b9a\u9700\u8981\u5bf9AO license\u8fdb\u884c\u521d\u59cb\u5316\u5de5\u4f5c\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u53ef\u4ee5\u770b\u51fa\uff0c\u8fd9\u91cc\u5bf9AO\u7684\u8c03\u7528\u751a\u81f3\u6bd4ADF\u91cc\u90fd\u8981\u7b80\u5355\uff0c\u521b\u5efa\u5bf9\u8c61\u76f4\u63a5\u7528new\u5173\u952e\u5b57\u5373\u53ef\u3002\u6b64\u4f8b\u4e2d\u4ec5\u4ec5\u6dfb\u52a0\u4e86\u4e00\u4e2a\u70b9\uff0c\u4f46\u7ebf\u548c\u9762\u7684\u7f16\u8f91\u5de5\u4f5c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u70b9\u6765\u5b8c\u6210\uff1b\u4e00\u4e9b\u7b80\u5355\u7684Geoprocessing\u5de5\u4f5c\u4e5f\u53ef\u4ee5\u901a\u8fc7\u4ee3\u7801\u800c\u4e0d\u662fGP Service\u6765\u5b8c\u6210\u4e86\u3002<br \/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;svc\u4e0easmx\u7684\u8c03\u7528\u5927\u540c\u5c0f\u5f02\u3002\u81f3\u6b64\uff0cSilverlight API\u7684\u7a0b\u5e8f\u53c8\u591a\u4e86\u4e00\u4e2a\u5f3a\u5927\u7684\u9760\u5c71\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Silverlight API\u7684\u5f00\u53d1\u5165\u95e8\u7cfb\u5217\u7684\u6587\u7ae0\u4e0a\u56de\u5df2\u7ecf\u7ed3\u675f\uff0c\u4f46\u5176\u5b9e\u80fd\u8bb2\u7684\u4e1c\u897f\u8fd8\u6709\u5f88\u591a\uff0c\u5b9e\u5728\u4e0d\u80fd\u9762\u9762\u4ff1\u5230\u3002\u8fd9\u6b21\u518d\u8865\u5145\u4e00\u4e2a\u6bd4\u8f83\u91cd\u8981\u7684\u529f\u80fd\uff0c\u5c31\u662f\u5728Silverlight API\u7a0b\u5e8f\u4e2d\u8c03\u7528ArcObjects\uff0c\u6765\u5b8c\u6210\u4e00\u4e9b\u590d\u6742\u7684geoprocess\u529f\u80fd\u3002&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADF\u4e4b\u6240\u4ee5\u5f3a\u5927\uff0c\u9664\u4e86\u5176\u672c\u8eab\u7684\u7c7b\u5e93\u5916\uff0c\u5b83\u8fd8\u80fd\u5728\u670d\u52a1\u5668\u7aef\u8c03\u7528AO\uff0c\u6765\u5b8c\u6210\u6bd4\u5982\u5728\u7ebf\u7f16\u8f91\u6216\u8005Geoemtry\u7684\u5904\u7406\u5de5\u4f5c\uff1b\u800cESRI\u5b98\u65b9\u7684\u8bf4\u6cd5\uff0c\u5efa\u7acb\u5728REST\u670d\u52a1\u57fa\u7840\u4e0a\u7684\u7a0b\u5e8f\u76ee\u524d\u90fd\u4e0d\u5177\u5907\u5728\u7ebf\u7f16\u8f91\u7684\u529f\u80fd\uff08\u56e0\u4e3a\u8981\u4e0e\u670d\u52a1\u5668\u7aef\u7684\u6570\u636e\u5e93\u6253\u4ea4\u9053\uff09\uff0c\u4f46\u4ed6\u4eec\u628a\u8fd9\u9879\u529f\u80fd\u4f5c\u4e3a\u65e5\u7a0b\uff0c\u63d0\u5230\u4e86\u7814\u53d1\u8ba1\u5212\u5185\u3002\u76ee\u524d\u800c\u8a00\uff0c\u8981\u5728Silverlight API\u4e2d\u5b8c\u6210\u6570\u636e\u7f16\u8f91\u5de5\u4f5c\uff0c\u4ed6\u4eec\u7684\u529d\u544a\u662f\uff0c\u201c\u5982\u679c\u4f60\u4e0d\u6015\u628a\u4f60\u7684\u53cc\u624b\u5f04\u810f\uff0c\u90a3\u5c31\u53bb\u505a\u5427\u201d\u3002&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u8a00\u5f52\u3002AO\u672c\u8eab\u662fCOM\u7ec4\u4ef6\uff0c.NET\u662f\u5229\u7528COM Interop\u6280\u672f\u4e0e\u5176\u6253\u4ea4\u9053\u7684\uff0c\u8fd9\u663e\u7136\u662fSilverlight\u7684\u5ba2\u6237\u7aef\u73af\u5883\u529e\u4e0d\u5230\u7684\u3002\u8fd9\u5c31\u9700\u8981\u4e0e\u670d\u52a1\u5668\u7aef\u8fdb\u884c\u901a\u4fe1\u3002Silverlight\u4e0e\u670d\u52a1\u5668\u7aef\u901a\u4fe1\uff0c\u6700\u5e38\u7528\u7684\u662fWebClient\u7c7b\uff0c\u7a0d\u590d\u6742\u7684\u8fd8\u6709HttpWebRequest\u7c7b\uff0c\u800c\u4f20\u7edf\u7684ASP.NET Web Service\u4e0e\u66f4\u5f3a\u5927\u7684WCF\u5219\u4e3a\u8fdc\u7a0b\u8c03\u7528AO\u63d0\u4f9b\u4e86\u53ef\u80fd\u3002\u4e0b\u9762\u8fd8\u662f\u6765\u770b\u4e00\u4e2a\u5b9e\u4f8b\uff0c\u529f\u80fd\u662f\u5728\u7a0b\u5e8f\u4e2d\u5411\u6570\u636e\u5e93\u4e2d\u6dfb\u52a0\u4e00\u4e2a\u70b9\uff0c\u4ee5Web Service\u4e3a\u4f8b\uff08\u5173\u4e8e\u5982\u4f55\u4f7f\u7528Web Service\u53ef\u4ee5\u67e5\u8d44\u6599\uff0c\u8fd9\u91cc\u4e0d\u505a\u8bb2\u89e3\uff09\u3002&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\u5728Silverlight\u6240\u5728\u7684ASP.NET\u5de5\u7a0b\u4e2d\u65b0\u5efa\u4e00\u4e2aASP.NET Web Service\uff0c\u6dfb\u52a0\u4e00\u4e2aWebMethod\uff0c\u5982\u4e0b\uff1apublic class WS_AOAddPoint : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return &#8220;Hello World&#8221;; } [WebMethod] public bool AddPointToFileGDB(double x, double y) { IAoInitialize aoInit = new AoInitializeClass(); aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine); IWorkspaceFactory pWSF = new ESRI.ArcGIS.DataSourcesGDB.FileGDBWorkspaceFactoryClass() as IWorkspaceFactory; ESRI.ArcGIS.esriSystem.IPropertySet pPropertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass(); pPropertySet.SetProperty(&#8220;DATABASE&#8221;, @&#8221;E:arcgisserveragsedit_simpleaddpointchina_airlines.gdb&#8221;); IFeatureWorkspace pFW = pWSF.Open(pPropertySet, 0) as IFeatureWorkspace; IPoint pPoint = new PointClass(); &hellip; <a href=\"https:\/\/blog.newnaw.com\/?p=35\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">ArcGIS API for Silverlight\u5f00\u53d1\u5165\u95e8\u5916\u4f20\uff1a\u5728\u7a0b\u5e8f\u4e2d\u8c03\u7528AO<\/span> <span class=\"meta-nav\">&raquo;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[8,24],"_links":{"self":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts\/35"}],"collection":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=35"}],"version-history":[{"count":0,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=\/wp\/v2\/posts\/35\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=35"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=35"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.newnaw.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=35"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}