Bus Route Finder Server Object Extension


Purpose
The purpose of this sample is to demonstrate use of Java and ArcObject types as parameters of methods in Server Object Extensions that are exposed as web services and are accessible through SOAP and REST.
 
This sample provides information about bus stations in Portland City and also generates directions to selected bus stations from user's location.

How to use

See How to use ArcGIS samples for help on running the sample.

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/mxds/portland.mxd and <Your ArcGIS Developer Kit Install directory>/Samples/data/portland/portland.gdb.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

BusServices REST SOE Schema
  1. Figure 1 below shows structure of BusServices SOE as a REST resource, i.e. its operation, sub-resource and operation on the sub-resource.
  2. If you follow instructions in this document to deploy this SOE to ArcGIS Server, the root URL of the SOE a REST resource would be http://<serverName>:8399/arcgis/rest/services/portland, with "portland" being the map service name.
  3. URLs in Figure 1 below are relative to the above root URL. For example, the final URL for the root resource would be http://<serverName>:8399/arcgis/rest/services/portland/MapServer/exts/BusServicesSOE.


  4. Figure 1: BusServices REST SOE Schema

How to deploy BusServices SOE to ArcGIS Server?
  1. Copy the BusServices_SOAPRESTExt.jar file that holds this SOE, from the $AGSDEVKITJAVA/java/samples/arcobjects/serverobjectextensions/busservices_soaprest/lib folder to $AGSSERVERJAVA/java/lib/ext folder.
  2. Alternatively, if you open this sample's Eclipse project in Eclipse IDE, you can export BusServicesSOE.java, IBusService.java, res/BusServicesSOE.wsdl and soe/javatypes/*.java files to a jar file and save the jar file to the $AGSSERVERJAVAjava/lib/ext folder. Please ensure that the WSDL file resides in the root folder of the SOE jar file.
  3. Log into ArcGIS Manager. Navigate to "Manager Extensions" page in "GIS Server" section.
  4. Refresh this page. If the jar file containing BusServices SOE indeed exists in $AGSSERVERJAVA/java/lib/ext folder, then ArcGIS Manager will display a record for this SOE on this page.
  5. Click on "Register" link next to the BusServices SOE.
  6. The BusServices SOE is now registered as extension to all Map Services.
  7. If the WSDL file is missing from SOE jar file, ArcGIS Manager will display an error accordingly. Make sure the WSDL resides in root folder of the jar file. ArcGIS Manager places this WSDL file into the $AGSSERVERJAVA/XmlSchema folder for later use.
  8. If using Windows 7, ArcGIS Manager will be unable to place WSDL file into $AGSSERVERJAVA/XmlSchema folder. Please place this WSDL file in the XmlSchema folder manually.

How to enable BusServices SOE with particular instance of Map service?
  1. Publish a map document as map service using ArcGIS Manager or ArcCatalog's "Publish GIS Resource" or "Add New Service" wizards.
  2. Create the map service using the "portland" map document from $AGSSERVERJAVA/java/samples/data/mxds folder. This sample SOE is designed to extend a map service that’s based on this portland map document only. We'll call this map service "portland".
  3. On the "Capabilities" page of "Publish GIS Resource" or "Add New Service" wizards, select the capability that matches with BusServices SOE. Ensure that the check box next to the capability is checked. If there is no capability that matches with "BusServices", please check if previous SOE deployment and registration step was executed correctly.
  4. If the SOE has capabilities of its own, please select the appropriate ones.
  5. Complete the publishing process and restart map service if necessary.
  6. Ensure that map service shows BusServices SOE as a capability after it is started, in ArcCatalog or ArcGIS Manager.

How to consume BusServices as a SOAP service?
  1. Import the "busservices_soaprest" Eclipse project from $AGSDEVKITJAVA/java/samples/arcobjects/serverobjectextensions.
  2. Navigate to src/arcgissamples/soe/soapclient package and ensure that BusServicesSOAPClient client application is present.
  3. Verify that BusServicesSOE_stubs.jar is present in the project's build path. This jar carries stubs for SOAP SOE's client application. This jar resides in the $AGSDEVKITJAVA/java/samples/arcobjects/serverobjectextensions/busservices_soaprest/lib folder.
  4. Ensure that the following jar files are also present in the project's build path: $AGSSERVERJAVA/java/lib/webservices/arcgis_agsws_stubs.jar, $AGSSERVERJAVA/java/lib/webservices/arcgis_ws_runtime.jar, $AGSSERVERJAVA/java/lib/shared/jsr173_1.0_api.jar, $AGSSERVERJAVA/java/lib/shared/jaxb-impl.jar, $AGSSERVERJAVA/java/lib/shared/jaxb-api.jar, $AGSSERVERJAVA/java/lib/shared/commons-logging-1.0.4.jar, $AGSSERVERJAVA/java/lib/shared/activation.jar, $AGSSERVERJAVA/java/lib/shared/commons-codec-1.3.jar, and $AGSSERVERJAVA/java/lib/shared/commons-httpclient-3.0.1.jar
  5. Compile and execute the soapclient/BusServicesSOAPClient Java application.
  6. Check the output messages of the application. This application instantiates the stub class using SOE's HTTP URL and makes a call to those methods that are exposed as operations in the WSDL.

How to access BusServices as a REST resource?
  1. This sample SOE can also be consumed as a REST resource. An SOE that exposed as a REST resource can be consumed using any application that can send HTTP requests and receive HTTP responses back.
  2. Open Services Directory web application (at http://<your server name>:8399/arcgis/rest/services/portland/MapServer).
  3. Scroll down the web page to "Supported Extensions:" section and click "BusServicesSOE" extension. The BusServicesSOE web page displays the BusServicesSOE SOE's name, description, some members of "Bus Station" collection, and links to the SOE's lone operation.
  4. Scroll down to the "Supported Interfaces:" section. Click "REST". This displays info about the resource in json format.
  5. Navigate back to "BusServicesSOE" web page.
  6. Click "Schema". The "Schema" page displays this resource's schema, i.e. its sub-resources, operations, parameters of each operation and supported output formats.

How to consume BusServices REST resource's operations?
  1. Navigate back to "BusServices" web page.
  2. Scroll down to the "Supported Operations: " section on the "BusServicesSOE" web page,
  3. Click the "findBusStationNearMe" link.
  4. Enter values for user location and distance in miles. Examples values could be {"x" : 7652726.886, "y" : 678771.121, "spatialReference" : {"wkid" : 102726}} for user location and 0.5 for distance in miles.
  5. Select output format.
  6. Click "findBusStationNearMe(GET)" or "findBusStationNearMe(POST)" button. All bus stations that are within 0.5 miles of user location will be displayed.

How to consume BusServices resource's sub-resources?
  1. Point your browser to the following URL: http://<your server name>:8399/arcgis/rest/services/portland/MapServer/exts/BusServicesSOE/BusStations/43. Details of bus station with id=43 will be display.
  2. Change the bus station id to any integer to view details of these bus stations.
  3. Scroll down to the "Supported Operations: " section.
  4. Click "getDirections".
  5. This is an operation of the BusStations sub resource. Since the BusStations sub resource is a collection, this operation can be invoked on each member of the collection.
  6. Enter user location (you can use the one mentioned in previous section) and click "getDirections(GET)" or "getDirections(POST)" button. Directions from user location to the current bus station will be displayed as one string.
  7. Try different combinations of bus ids and user locations.

How to disable BusServices SOE with "portland" Map service?
  1. Use ArcGIS Manager or ArcCatalog to access "portland" map service's properties.
  2. On "Capabilities" page, uncheck the check box next to BusServices Capability.
  3. Save the map service and restart it if necessary.
  4. The BusServices SOE is now disabled on the "portland" map service.

How to un-deploy BusServices SOE?
  1. Log into ArcGIS Manager. Navigate to "Manager Extensions" page in "GIS Server" section.
  2. Click "UnRegister" link next to BusServicesSOE.
  3. The BusServices SOE is now unregistered from ArcGIS Server.
  4. Remove the SOE's jar file from $AGSSERVERJAVA/java/lib/ext folder.


Download the files for Java
soe/BusServicesSOE.java The Bus Services Java Server Object Extension
soe/IBusService.java A custom interface that exposes the SOE's SOAP callable methods. The above SOE implements these method.
soe/soapclient/BusServicesSOAPClient.java A client console application that consumes the SOE's web service through Internet connection.
res/BusServicesSOE.wsdl A WSDL file that provides information about which methods are made available to this SOE's SOAP clients.
lib/BusServicesSOE_stubs.jar A jar file that contains proxies to generate and send SOAP requests to this SOE.
soe/javatypes/*.java Custom Java types used by SOE




Development licensing Deployment licensing
Server Server