How to query a non-ArcGIS database from WAB?

5181
41
Jump to solution
01-12-2017 02:35 PM
WilliamMiller4
Occasional Contributor II

Hi,

I need to send information from my WAB app to a non-ArcGIS database, run a query and return the results back to my app. From what I see online, using only JavaScript is not a secure idea. It looks like I need an intermediary, which my employer would like to be Visual Basic. If someone has successfully done this, please let me know how I might go about it. Any help is appreciated. Thank you for your time.

William

0 Kudos
1 Solution

Accepted Solutions
Drew
by
Occasional Contributor III

You would have to know the database, table name and the credentials to connect to the database.

• Assuming it’s a SQL Server database, its just like connecting to SDE and adding data the same way.
• Add a database connection in ArcCatalog
• In ArcMap just use the add data button and browse to your table.
• Once added got to the table of contents and select the ‘List by Source’ icon to see the able listed.
• Publish to ArcGIS Server
o You might have to register the database with ArcGIS Server
• Navigate to the map services REST endpoint and look for your table.
• You now have a layer you can query using the JSAPI

Drew

View solution in original post

41 Replies
RobertScheitlin__GISP
MVP Emeritus

William,

   JS does not have any database access ability like native languages do so you would have to use a web service to query and return json or xml to the JS client. I do this for several of my sites but I am an experinced .Net and JS developer. You can search the web for VB.net RESTfull web service examples as a starting point (the majority you will find will be for C# though).

WilliamMiller4
Occasional Contributor II

Hi Robert,

I have a very basic web service. How do I send the search criteria collected from a widget with JavaScript to that web service?

William

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

  With some code like this:

        var requestHandle = esriRequest({
          url: 'your rest service url',
          content: {
            ppin: ppin,
            f: 'json'
          },
          handleAs: "json",
          timeout: 10000
        },{useProxy: true, usePost: false, disableIdentityLookup: true});
WilliamMiller4
Occasional Contributor II

Hi Robert,

I have a couple questions.

If I use XML instead of JSON, is the following format correct?

var requestHandle = esriRequest({
  url: 'your rest service url',
  content: {
    xmlContent: xmlContent
  },
  handleAs: "xml",
  timeout: 10000
},{useProxy: true, usePost: false, disableIdentityLookup: true});
requestHandle.then(requestSucceeded, requestFailed);‍‍‍‍‍‍‍‍‍

If I'm running Web AppBuilder on my desktop, can I still test this functionality?

Thank you for your help.

William

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

  Assuming that your web service has one input parameter and it is called "xmlContent" then yes. You should be able to put a console statement in the requestSuceeded function to show the results of the request. I not sure the reason you choose xml as the defacto standard now a days is json though.

0 Kudos
WilliamMiller4
Occasional Contributor II

Hi Robert,

I've been having trouble creating a new web service, so I was trying the one that was used with flexviewer. That web service however is SOAP. I asked the guy who developed it what the input parameter name was and he said it wasn't named.

William

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

William,

   You will not be able to use a SOAP service, that is why I mention a RESTfull web service was needed.

0 Kudos
Drew
by
Occasional Contributor III

As mentioned below, maybe you don't even need a service.
Can you add the 'non-ArcGIS database' as a table in the Map Document (mxd) and publish it?

Once in the service you can just query it like any ArcGIS service.

WilliamMiller4
Occasional Contributor II

Hi Drew,

The database I need to connect to has real estate information that is updated regularly. I don't know, but I would guess that adding a table would not work for this situation. Please correct me if I'm wrong. I don't know much about Map Documents.

William

0 Kudos