This topic explains how to create and build a Java REST server object extension (SOE) using the Maven command line. You can generate a project in either interactive or non-interactive mode, configure the service type, and package the SOE for deployment to ArcGIS Server.
- Create the REST SOE project
- Configure the SOE service type
- Build the REST SOE project
- Deploy and test the REST SOE
Before proceeding, install the ArcGIS Enterprise SDK, a supported JDK, and Apache Maven. You must also install the SDK Maven artifacts into your local Maven repository. See Installation for setup instructions.
The examples below target ArcGIS Enterprise SDK 12.2 and use Maven archetype version 12.2.0. Verify that this version is included in the Maven artifacts installed with your SDK before running the commands.
Create the REST SOE project
The rest-soe-archetype Maven archetype generates a Java REST SOE project. You can use interactive mode to enter project properties when prompted or non-interactive mode to supply them in one command.
Use the Maven command in interactive mode
You can open the command prompt for Windows or Linux terminal and use the following Maven command to create a REST SOE project in interactive mode:
mvn archetype:generate -DarchetypeGroupId=com.esri.arcgis.enterprise.sdk -DarchetypeArtifactId=rest-soe-archetype -DarchetypeVersion=12.2.0For other versions of Enterprise SDK, remember to change - to the corresponding version of the SDK, such as - for 12.2 Enterprise SDK.
You need to specify the same version of the SDK you are using as the - parameter.
After executing the above command, you are prompted to enter values for the following properties:
- groupId: Type
entsdksamples.soe. - artifactId: Type
simplerestsoeas the project's name. - version: Press Enter to skip this property. This uses the default value
1.0-, indicating this project is still in development.SNAPSHOT - package: Press Enter to skip this property. This uses the groupId's value as the package name.
- soeName: Type
JavaSimple RESTSOE - Y: Type
Yto confirm your inputs.
For additional information about Maven project properties, see Project creation.
Use the Maven command in non-interactive mode
If you would like to create the SOE or SOI project without interactivity, you can set the interactive property to false (-), or use the - flag (see generate project in batch mode).
The following command will achieve the same result as the project above created in interactive mode:
mvn archetype:generate -B -DarchetypeGroupId=com.esri.arcgis.enterprise.sdk -DarchetypeArtifactId=rest-soe-archetype -DarchetypeVersion=12.2.0 -DsoeName=JavaSimpleRESTSOE -DgroupId=entsdksamples.soe -DartifactId=simplerestsoe -Dversion=1.0-SNAPSHOTMaven creates the simplerestsoe project directory using the supplied properties. The generated Java sources are under src/main/java.
Configure the SOE service type
After creating the project, configure the type of ArcGIS Server service the SOE will extend.
-
Open the generated
Javafile underSimple RESTSO E.java src/main/java. -
Locate the
@annotation on the SOE class.Server Object Ext Properties -
Set the annotation's
servicetypeattribute to the appropriate value:Value Target service "Map Service" ArcGIS Server map service "Image Service" ArcGIS Server image service For a map service, retain the default setting:
Use dark colors for code blocks Copy servicetype = "MapService"For an image service, change it to:
Use dark colors for code blocks Copy servicetype = "ImageService" -
Save the Java file. If you select
Image, review the generated source code and replace map-service-specific interfaces, operations, and business logic with implementations supported by image services.Service
The servicetype attribute identifies the service type on which the SOE can be enabled. Changing this attribute does not automatically make the generated map-service sample compatible with image services.
Build the REST SOE project
Navigate to the generated project's root directory (the directory containing pom.xml), and run:
cd simplerestsoe
mvn clean installThe clean phase removes previous build output. The install phase builds and packages the project and installs its Maven artifact in your local repository. The ArcGIS Enterprise SDK Maven packaging plugin generates the deployable .soe file during the build.
After a successful build, look for the generated SOE package in the target directory, typically:
target/simplerestsoe.soeIf the build fails, confirm that the SDK Maven artifacts are installed, that the POM references the correct SDK version, and that Maven is using the supported JDK. For more information, see Project build.
Deploy and test the REST SOE
Building the project does not deploy the SOE to ArcGIS Server. To use it:
- Deploy and register the extension with a compatible ArcGIS Server site.
- Enable the extension on a service of the type specified by
servicetype. - Open the service in the ArcGIS Server Services Directory and verify that the SOE is listed among the supported extensions. Test the operations implemented by the SOE.
For an example of testing the Simple REST SOE in the Services Directory, see Consume the SOE using the Services Directory.
Note: The sample's resources and operations are map-service-specific. When targeting an image service, test the operations implemented by your image-service-compatible SOE instead.