0

I want to identify number of layers in to workspace in GeoServer for that I am using below REST API:

http://admin:geoserver@localhost:8080/geoserver/rest/workspaces/gisc/featuretypes.json?callback=?

My application is running on IIS so I am using JSONP. I have enabled JSONP in GeoServer but I can not get output, always getting error "**Uncaught SyntaxError: Unexpected token :"

I tried:

var url  = "http://admin:geoserver@localhost:8080/geoserver/rest/workspaces/gisc/featuretypes.json?callback=?";

$.ajax({
 type: 'GET',
 url: url,
 async: false,
    jsonpCallback: 'parseResponse', 
    contentType: "application/json",
    dataType: 'jsonp',  
    success: function(data)
    {
        console.log(data);
    },
    error: function (e)
    {
        console.log(e);
    }
 });

I have also tried another combination but it won't work I am always getting same error.

I have also tried to enable CORS in Jetty using "org\mortbay\servlets\CrossOriginFilter.class" it works with WMS and WFS but won't work with featuretypes.json.

nmtoken
  • 13,355
  • 5
  • 38
  • 87

1 Answers1

1

The GeoServer REST API is used purely for management of the GeoServer instance and should not be confused with the ESRI Rest interface.

If you want to interrogate GeoServer about layers you need to use one of the OGC open standard interfaces provided.

  • WMS - for rendered maps
  • WFS - for vector features
  • WCS - for raster coverages

In each case there is a well defined API which always includes a GetCapabilities request to tell you what operations and "layers" are available. These are always implemented as an HTTP GET request to the endpoint with the Key Value pairs of SERVICE and REQUEST=GetCapabilities and optionally a VERSION to determine the version of the specification you require.

If you are just trying to turn CORS on then see Enabling CORS in GeoServer (jetty)?

Ian Turton
  • 81,417
  • 6
  • 84
  • 185