I can get a WMS GetCapabilities response via AJAX call and I can convert response to JSON using ol.format.WMSCapabilities tool.

But I need to make a WFS GetCapabilities query via a AJAX request and get a JSON result.

How can I do it?

My GetCapabilities operation metadata is like this:

enter image description here


For versions of the WFS interface standard prior to version 2.0, the only format supported as a response was XML.

From WFS version 2.0 whilst a WFS GetCapabilites defaults to XML a request can now include an AcceptFormats parameter which must include the "text/xml" value, but may include other vendor specified formats.

So you could make a request like:


If the server supports WFS 2.0 it will give you a JSON response if it supports it as a GetCapabilites response format, otherwise it will give you XML. If the server is not WFS 2.0 it will ignore the AcceptFormats parameter and give you XML.

  • I updated the post with an image of Operations metadata – barteloma Aug 11 '17 at 7:54
  • So in this case you can only get XML from the service. – nmtoken Aug 11 '17 at 7:57
  • What can I do to support application/json? Installing another geoserver version or change existing geoserver settings? – barteloma Aug 11 '17 at 8:01
  • 1
    Not sure if it's possible using geoserver at the moment. That's probably a question worth asking on the geoserver-dev mail list. Otherwise, if you don't need to use WFS 2, you can try the route suggested by @bartvde – nmtoken Aug 11 '17 at 8:16
  • 1
    See the capabilities of demo.geo-solutions.it/geoserver/…. The response shows ows:Operation name="GetCapabilities" - ows:Parameter name="AcceptFormats" - ows:Value>text/xml</ows:Value. GeoServer does not support any additional formats for GetCapabilities. You must contact (or contract) developers. – user30184 Aug 11 '17 at 9:09

You can use JSONIX and ogc-schemas for this

const wfsContext = new Jsonix.Context([OWS_1_0_0, Filter_1_1_0, SMIL_2_0, SMIL_2_0_Language, XLink_1_0, GML_3_1_1, WFS_1_1_0]);
const wfsUnmarshaller = wfsContext.createUnmarshaller();

var info = wfsUnmarshaller.unmarshalDocument(xmlhttp.responseXML).value;

See here for more example code: https://github.com/boundlessgeo/sdk/blob/master/src/services/WFSService.js#L80


Maybe you can make use of this code on GitHub:


npm install wms-capabilities --save
var WMSCapabilities = require('wms-capabilities');
new WMSCapabilities().parse(xmlString);
new WMSCapabilities(xmlString).toJSON();`

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.