REST API requests using Java SDK?

1942
6
09-16-2021 05:26 PM
NickRobles2
New Contributor II

IS there any functionality in the Java SDK that allows for interactions on a REST? For instance, I am trying to access the attachments on a published service or just pull general information about the table or layer. 

I found that there is MapServerBindingStub but those functions appear to be for SOAP only. Currently I am doing this through custom code by getting JSON requests and parsing those, which is fine, but I want to make sure I am not missing anything in the API that I could be using instead to make things easier. 

Tags (3)
0 Kudos
6 Replies
MarkBaird
Esri Regular Contributor

When you say the Java SDK, I want to make sure you are talking about this product which is for writing desktop apps with JavaFX?  Note that this API is not for writing server components in microservices for example, this is a client side API.

If this is the product you are referring to then the answer is yes, we have lots if API which effectively wraps the ArcGIS Rest API so you can use it in Java code easily.

There is a sample app in git which shows how to work with attachments alongside many others which explain common workflows.

Does this help?

NickRobles2
New Contributor II

Hi Mark!

 

Thanks for the reply. This does help and it seems I have been using an outdated ArcGIS WebService Engine Runtime, and not the Java SDK. That being said, would this wrapped REST API allow me to work with published feature layers on an ArcGIS Server? 

 

Also, I hate to be so needy but could you link me to examples of the Java API that wraps the REST API? I have checked in the github link you provided for examples and I can't seem to find examples for making GET requests/queries against a map service

0 Kudos
MarkBaird
Esri Regular Contributor

@NickRobles2 I want do double check that you are intending on developing a JavaFX Desktop app which runs on Windows, Linux or Mac?  If this is the case, you are in the right place and I can help you.

If you are writing a server side component then the ArcGIS Runtime for Java product is not what you should be using. If you are writing a server component then I'll point you in a different direction to help you.

If you are writing desktop JavaFX apps, then let me know what you are trying to do and I'll point you at the relevant doc and samples.  

0 Kudos
NickRobles2
New Contributor II

@MarkBaird sorry for the lack of clarity. I guess I am not sure but I am open to both options. Essentially I would like to build a webapp with java on the backend that can do GET and POST against a published service on an ArcGIS Server to query, edit features, and grab attachments from those published services and also be able to commit attachments and general feature data into a db such as oracle or postgres

0 Kudos
Nicholas-Furness
Esri Regular Contributor

Hi @NickRobles2 ,

We're trying to work out where to move the question to get you the best answer. Can you tell me a bit more about why the back-end will interact with services rather that the app doing that? And does it have to be built in Java, or are you open to other technologies?

A little background, probably you know a lot of this:

The general model we follow for web apps is to let the services do any interaction with the db, abstracting direct db access into a set of REST APIs. Those REST APIs (which also cover other things you mentioned, like query, edit, working with attachments, reading service metadata, etc.) are documented here: https://developers.arcgis.com/rest/

We have many APIs that work with those REST APIs, and they broadly break down into APIs for working directly with services, and APIs for building 2D/3D apps using those services.

The former are a couple of APIs that wrap GET/POST/etc. calls to the REST APIs: the ArcGIS REST JS API, and the ArcGIS API for Python. The Python API has been around longer and has more capabilities, but is for building apps and scripts that process data, so probably not what you want. ArcGIS REST JS is more suited to building a server-side component to support web clients. This sounds closest to what you're asking for, but is JavaScript.

Of the group of APIs we have for building 2D and 3D apps, there is the ArcGIS API for JavaScript, and the ArcGIS Runtime SDKs. Both are meant for building apps, and using Runtime SDKs to build a backend services is against our terms and conditions.

One other potential option: If you already have ArcGIS Enterprise and expose services, and just want to expose more sophisticated behavior for those services, then Server Object Extensions (SOEs) and Server Object Interceptors (SOIs) are likely a good solution.

It boils down to:

  1. Do you really need to have this logic in the back-end or can it be in the web app, hitting services?
  2. If SOEs and SOIs will do the job for you, I'll move this question over to here. If not, you'll need to keep working with the REST services. If the backend can be written in JavaScript, you might be able to lean on the ArcGIS REST JS API.

Does that help?

0 Kudos
MarkBaird
Esri Regular Contributor

@NickRobles2 I'm going to ask one of the forum admins to move your post to somewhere you can get help with this from an ArcGIS Server point of view...  watch this space!

0 Kudos