1

I'm trying to send a WFS request to my Geoserver but there is something wrong. Here's what I get when I select the JSONP:

http://130.239.57.16:8080/geoserver/beta/ows?service=WFS&version=1.0.0&request=GetFeature&typeName=beta:states&maxFeatures=50&outputFormat=text%2Fjavascript

Here's the javascript:

    var owsrootUrl = 'http://130.239.57.16:8080/geoserver/ows';

var defaultParameters = {
    service : 'WFS',
    version : '1.0',
    request : 'GetFeature',
    typeName : 'beta:admin>',
    outputFormat : 'text/javascript',
    format_options : 'callback:getJson',
    SrsName : 'EPSG:4326'
};

var parameters = L.Util.extend(defaultParameters);
var URL = owsrootUrl + L.Util.getParamString(parameters);

var WFSLayer = null;
var ajax = $.ajax({
    url : URL,
    dataType : 'jsonp',
    jsonpCallback : 'getJson',
    success : function (response) {
        WFSLayer = L.geoJson(response, {
            style: function (feature) {
                return {
                    stroke: true,
                    fillColor: '#FF0000',
                    fillOpacity: 0
                };
            },
            onEachFeature: function (feature, layer) {
                popupOptions = {maxWidth: 200};
                layer.bindPopup("Popup text, access attributes with feature.properties.ATTRIBUTE_NAME"
                    ,popupOptions);
            }
        }).addTo(map);
    }
});

Nothing shows up on the web page, and Firebug shows that the request is made to the server, but the response is:

http://schemas.opengis.net/wfs/1.0.0/OGC-exception.xsd"> Feature type beta:states> unknown

It seems like the feature type is unknown, but I don't know now to fix it.

3
  • I just tried that URL, and it works for me. Your javascript doesn't actually point to that URL though.
    – BradHards
    Commented Oct 16, 2015 at 7:52
  • both urls work for me
    – Ian Turton
    Commented Oct 16, 2015 at 8:31
  • Interesting BradHards -- can you elaborate? I'm not seeing it, thanks!
    – Encomium
    Commented Oct 16, 2015 at 11:55

1 Answer 1

1

You have a typo in your script.There is a letter ">" in your layername.

Its typeName : 'beta:admin' and not typeName : 'beta:admin>' (but obviously a layer named "beta:admin" is not published in your geoserver)

for your states-layer it's:

var defaultParameters = {
    service : 'WFS',
    version : '1.0',
    request : 'GetFeature',
    typeName : 'beta:states',
    outputFormat : 'text/javascript',
    format_options : 'callback:getJson',
    SrsName : 'EPSG:4326'
};

http://jsfiddle.net/hqmjc4nw/

1
  • totally -- thanks for spotting that Thomas :) appreciate your time.
    – Encomium
    Commented Oct 23, 2015 at 16:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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