WebServices call AO Method

Source: Internet
Author: User

1. ServerCode:

 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)]
// To allow ASP. Net ajax to call this web service from a script, uncomment the downstream service.
// [System. Web. Script. Services. scriptservice]
Public Class Service: system. Web. Services. WebService
{
Public Service (){

// If you use the designed components, uncomment the following lines:
// 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: \ data \ 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 client code:

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 button#click (Object sender, eventargs e) {addpointserver. service Se = new addpointserver. service (); se. addpointtofilegdbcompleted + = new ADDP Ointserver. 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. Note: The directory where file GDB is located must have the read and write permissions for the ASPnet and NetworkService roles. Otherwise, the file GDB cannot be read or written.

4. How can I makeFolder PropertiesPage has"Security"Tab? The solution is as follows:

1,  Open Resource Manager 2,  Go to the tool-Folder option menu and switch to the "View" tab. 3,  Remove the "use simple file sharing (recommended)" option

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.