Workflow: Using ArcGIS Spatial Data Server for IIS to serve database data

Complexity: Beginner Data Requirement: Use your own data

You can set up ArcGIS Spatial Data Server for IIS and publish data from your existing database by following the example presented in this topic. Simply replace the specific information (spatial data server name, database name, user name, and so on) with information appropriate to your site.

In this example, an application will be created to allow customers of a waste hauler to request new bin delivery or schedule large item pickups.

A customers feature class in a SQL Server database will be published as an editable feature service and a service_area feature class will be published as a read-only feature service to the spatial data server.

Deploy a spatial data server

First, set up the spatial data server, user, and data source.

Install ArcGIS Spatial Data Server for IIS

To install ArcGIS Spatial Data Server for IIS, follow the instructions in the installation guide provided with the software. This guide includes information about system requirements, IIS requirements, authorization, and installation of the software.

NoteNote:

To allow editing through your published services on ArcGIS.com, you must install ArcGIS Spatial Data Server on a public server (one outside your firewall).

Grant privileges to the connecting user

When you get to the next set of steps, you will specify a user to connect to the data source. That user must be granted privileges on the datasets you want to publish to the spatial data server. For example, if you want users to have query-only access to the data in your feature service, the user specified for the data source only needs to have select privileges on the datasets in the feature service.

In this workflow example, the feature service will allow query and create privileges; therefore, the user connecting to the data source must be granted select and insert privileges on the customers feature class.

As shown here, a login, webeditor, is created in the SQL Server instance and added to the database, threers. A schema is then created for the database user, and the user is granted select and insert privileges on the customers feature class:

CREATE LOGIN webeditor WITH PASSWORD=N'We4Svcs', 
  DEFAULT_DATABASE=threers, 
  CHECK_EXPIRATION=OFF, 
  CHECK_POLICY=ON;
GO

USE threers;

CREATE USER webeditor FOR LOGIN webeditor;
ALTER USER webeditor WITH DEFAULT_SCHEMA=webeditor;
GO

CREATE SCHEMA webeditor AUTHORIZATION webeditor;
GO

GRANT SELECT,INSERT
  ON cdata.customers
  TO webeditor;

Create a data source

When you create a data source, you tell the spatial data server which database to connect to and as what user.

You can create multiple data sources, but for this example, only one is required.

Steps:
  1. Open a web browser and go to the REST API Admin view for your spatial data server. The URL for this is in the format http://<server name>/<spatial data server name>/admin.

    In this example, the spatial data server is installed on server webapps and the spatial data server is sdsi2s; therefore, the REST API Admin endpoint URL is http://webapps/sdsi2s/admin.

  2. Click the Datasources link, then click the Create Datasource link to open the Create Datasource page.

    Create Datasource page

  3. Provide the information required:
    1. Type a name and description for your new data source. In this example, the data source name will be cust_reqs.
    2. Server is the name of the DBMS instance in which the database resides. For this example, the SQL Server instance name is abe\sspub.
    3. Database is the name of the database that contains the data you want to publish. In this example, the database is threers.
    4. Provide the user name (webeditor) and password (We4Svcs) that was created in the last section.
    5. Once you have typed the correct information, click Create Datasource.

Set up an ArcGIS Online account

In this example, the service will be published to ArcGIS Online, where an application will be created.

You use your Esri Global Account to sign in to ArcGIS Online. You can register your existing Esri Global Account with ArcGIS Online or create an Esri Global Account and register it from the same place. Go to http://www.arcgis.com/home/ and click Sign In.

If you have already registered your Esri Global Account with ArcGIS Online, you do not need to sign in at this time. This will be done later in the workflow when the service is published.

Create an administrator connection to the spatial data server

You publish data through a specific connection to the spatial data server. The administrator connection allows you to adminster the server and publish services.

Since you might also want to administer your spatial data server, create an administrative connection to your spatial data server from ArcGIS for Desktop.

Steps:
  1. Start ArcMap and open the Catalog window.
  2. In the Catalog tree, expand the GIS Servers node.
  3. Double-click Add ArcGIS Server.
  4. Choose Administer GIS server, and click Next.
  5. In the Server URL text box, type the administrative URL of the spatial data server.

    For this example, the URL is http://webapps/sdsi2s/admin.

  6. Choose Spatial Data Server from the Server Type drop-down list.
  7. If you will be using this connection to create and save service definitions, you can choose where the service definition files will be staged on disk. By default, they are staged in a folder on your local machine.
  8. Click Finish to create the connection.

    Your new connection is listed under the GIS Servers node.

Publish feature services

You will publish two services: one that will be edited to accept the requests, and one read-only service that denotes your service area. To share your services with others, connect to your database from ArcMap, author two separate maps in ArcMap—one for the editable service and one for the read-only service—and publish each one.

Connect to the database from ArcGIS for Desktop

You make a connection to your database so you can access the data in it. To make a connection to the database, you must install the database client on the computer where ArcGIS is installed.

For this workflow, you need the SQL Server Native Client supported for the release of the SQL Server database you are using. Obtain this client from Microsoft and install it on your client computer.

Once the SQL Server Native Client is installed, you can make a connection from ArcMap to your database.

Connect to your database from ArcMap so you can add the customers table to your map.

Steps:
  1. In the Catalog tree, expand the Database Connection node.
  2. Double-click Add Database Connections.
  3. Choose SQL Server from the Database Platform drop-down list.
  4. Type the name of the SQL Server instance, abe\sspub, in the Instance text box.
  5. Type the database name, threers, in the Database text box.
  6. Choose Database authentication from the Type drop-down list.
  7. Type webeditor in the User name text box.
  8. Type We4Svcs in the Password text box.
  9. Leave Save user name and password checked, and click OK.

Author a map for the editable service

Add the customer table to ArcMap by dragging it from the database connection to the map window.

If ArcMap cannot detect the spatial reference or a qualifying ObjectID column (a not null integer column), you will be prompted to provide that information.

NoteNote:

You cannot publish data that does not have a spatial reference.

Once the table appears in the ArcMap table of contents, symbolize the features using simple symbols that you want to appear in the service. See the ArcGIS help for information on how to change symbology.

Next, make any configuration changes in the map document needed for the properties you want to expose in the service. For example, you will likely want to set which fields will be visible through the service, set aliases for the fields that will be visible, and possibly set some fields as read-only. For this example, you would also want to set up an HTML pop-up menu for users to provide the information needed to process their request. See A quick tour of authoring feature services for a spatial data server for a list of possible properties.

Zoom to the initial extent you want your service to use. You want to be sure that the initial extent will return no more than the maximum number of features you set at the time of publishing for the service to return. By default, that number is 1000. Save your map.

Publish an editable feature service

Now that your map is ready, share your data as a feature service by publishing it.

Steps:
  1. In your ArcMap document, choose File > Share As > Service from the main menu.
  2. In the Share As Service window, there are three options.
    • To immediately publish your data, choose Publish a service and click Next.
    • To save a service definition file to be published later, choose Save a service definition file and click Next.
    • To replace an existing service, choose Overwrite an existing service and click Next. To replace a service, the original service must be stopped first.
  3. Choose your admin spatial data server from the connection drop-down list.
  4. Type three_r_requests in the Service Name text box and click Continue.
  5. Click Feature Access in the Service Editor.
  6. Uncheck Delete and Update since users will only be able to query the service and add features to it.
  7. Leave the The maximum number of features returned per query set to 1000.
  8. Click Sharing.

    The ArcGIS Online Sign In dialog box opens.

  9. Type your Esri Global Account user name and password and click OK to sign in and close the sign in dialog box.
  10. In the ArcGIS Online pane of the Service Editor dialog box, check the appropriate box for whom you want to be able to access your content.
    • If you are the only one to access the service for now, check My Content.
    • If you want everyone who has access to ArcGIS Online to see the service, check Everyone (public).
    • Any groups of which you are a member are listed. If you want to grant access to your service to any of these groups, check Members of these groups, then check all groups you want.

    You can check more than one option. For example, you might want the service to be part of your content and grant access to specific ArcGIS Online groups.

  11. Click Analyze to be sure there are no errors or warnings to correct before you publish.

    Errors must be corrected or publishing fails.

  12. If you want to see how the feature class will look in the service, click Preview.
  13. At this point, you could save the service definition file to publish at a later time. However, for this workflow, publish the service.
  14. Click Publish.
  15. When publishing completes, click OK to close the dialog box.

Author a map for the read-only service

Create a second map from which you will publish the read-only service.

Steps:
  1. Open a new map in ArcMap: File > New.
  2. Choose New Maps and click OK.
  3. Drag your service_area feature class onto the map.
  4. Symbolize the layer as you want it to appear in the service.

    Use either no fill for the service area polygon or set the fill to be transparent.

  5. Set which fields will be visible through the service and set aliases for those fields.
  6. Save the map document in a shared directory to which the local IIS APPPOOL\DefaultAppPool user has access.

Publish the read-only service

Publish the second map so it can be used as a point of reference in your web application.

Steps:
  1. In your ArcMap document, choose File > Share As > Service from the main menu.
  2. In the Share As Service window, there are three options.
    • To immediately publish your data, choose Publish a service and click Next.
    • To save a service definition file to be published later, choose Save a service definition file and click Next.
    • To replace an existing service, choose Overwrite an existing service and click Next. To replace a service, the original service must be stopped first.
  3. Choose your admin spatial data server from the connection drop-down list.
  4. Type service_area in the Service Name text box and click Continue.
  5. Click Feature Access in the Service Editor.
  6. Type the URL of a public server in the URL text box.

    You must publish editable feature services to a public server for ArcGIS Online to be able to access it.

  7. Uncheck Add, Delete, and Update since users will only be able to query this service.
  8. Click ArcGIS Online.

    The ArcGIS Online sign in dialog box opens.

  9. Type your Esri Global Account user name and password and click OK to sign in and close the sign in dialog box.
  10. In the ArcGIS Online pane of the Service Editor dialog box, check the appropriate box for who you want to be able to access your content.
    • If you are the only one to access the service for now, check My Content.
    • If you want everyone who has access to ArcGIS Online to see the service, check Everyone (public).
    • Any groups of which you are a member are listed. If you want to grant access to your service to any of these groups, check Members of these groups, then check all groups you want.

    You can check more than one option. For example, you might want the service to be part of your content and grant access to specific ArcGIS Online groups.

  11. Click Analyze to be sure there are no errors or warnings to correct before you publish.

    Errors must be corrected or publishing fails.

  12. If you want to see how the feature class will look in the service, click Preview.
  13. At this point, you could save the service definition file to publish at a later time. However, for this workflow, publish the service.
  14. Click Publish.
  15. When publishing completes, click OK to close the dialog box.

View your services

You can view information about your service from the ArcGIS Spatial Data Services Directory. Since you published your service to ArcGIS Online, you can view the service on a map from there.

Access the service from the ArcGIS Spatial Data Services Directory

The ArcGIS Spatial Data Services Directory lists all services published to a specific spatial data server. From here, you can export your service definition as a JSON file, write SQL queries to select or insert features to the feature class, or open your service in ArcGIS.com.

The URL for the ArcGIS Spatial Data Services Directory is http://<server name>/<spatial data server name>/rest/services. Therefore, for this example, the URL is http://webapps/sdsi2s/rest/services. You will see both services listed.

Use ArcGIS Online

Now that you have published the feature classes to your spatial data server, you can view them from ArcGIS Online.

Steps:
  1. Open a web browser and go to the ArcGIS Online website at http://www.arcgis.com/home/index.html.
  2. Click Sign In.
  3. Type your Esri Global Account user name and password and click Sign In.
  4. Click My Content.
  5. Add the three_r_requests service first.
    1. Click Add Item.
    2. Choose On the Web from The item is drop-down list.
    3. Type the URL to the service.

      For this example, the URL is http://webapps/sdsi2s/rest/services/three_r_requests.svc.

    4. Type a title for your service in the Title text box.
    5. Type tags to identify your service in the Tags text box.
    6. Click Add Item.
  6. Follow the same procedure to add your service_area service to your content.

Create a web application

First, create a map on ArcGIS.com that contains your services and a basemap of streets for the area. Next, use an application template from ArcGIS.com to create a web application.

Create a map on ArcGIS.com

Add both your services to a basemap on ArcGIS.com and save the map to use for your application.

Steps:
  1. In the My Content section of ArcGIS.com, click your read-only service.
  2. Click Open to open a map that shows the data in that service.
  3. Click Add, then choose Add Layer from Web to add your second service.

    The Add Layer from Web dialog box opens.

  4. Type the URL of your editable service in the URL text box and click Add Layer.
  5. Click Basemap and choose one of the layers that shows street names.
  6. Adjust the extent of your map, if necessary, to just cover the extent of both services.
  7. Click Save to save your map.
    1. Type a title, tags, and summary for the map.
    2. Choose in which folder to save the map.
    3. Click Save Map.
  8. Share your map either publically or with specific groups.
  9. Take note of the ID for your map; you will use this when creating a web application.

Use a template to create a web application

Since the application needs to allow editing, you will use the Edit web application template.

Steps:
  1. Download the Edit web application template.
  2. Place the downloaded zip file in the inetpub\wwwroot folder on your IIS server.
  3. Extract the files.
  4. Follow the instructions in the readme.html file to set up the application.
7/19/2012