I've been beating my head against this on all day ..
I need to request a list of available layers from my geoserver (this list will
change depending on whether the user is logged in or not).
The obvious thing is to use either OpenLayers.Format.WFSCapabilites + GET, or
GeoExt.data.WFSCapabilities. They won't work without a proxy.
However, for a number of reasons, I don't want to set up a proxy server. For
one thing, if I set up an Apache server, THE ONLY THING IT WILL EVER DO is be a
proxy for geoserver, and that seems beyond ridiculous.
As an alternative, I've been trying to parse the json response from REST:
jsonurl=
'http://localhost:8080/geoserver/rest/workspaces/MHC/datastores/Inventory/featuretypes.json';
wfs_store = new
Ext.data.JsonStore({
autoLoad: true,
fields:
['name'], //I've tried a few different iterations of root/fields
structure here
proxy: new
Ext.data.ScriptTagProxy ({
url: jsonurl
})
});
wfs_store.load();
wfs_store.on('load', function()
{
record =
wfs_store.getAt(0);
alert(record.data.name);
});
This doesn't work (wfs_store is always empty and record is always undefined),
though I can tell from Firebug that it's getting the expected response. It
seems like the json response from geoserver isn't quite in the format that
Ext.data.JsonStore expects to see?
This is the geoserver json response:
{"featureTypes":{"featureType":[{"name":"Inventory_Areas",
"href":"http:\/\/localhost:8080\/geoserver\/rest\/workspaces\/MHC\/datastores\/Inventory\/featuretypes\/Inventory_Areas.json"}]}}
(As an example, I'm comparing this to the output from ESRI's geocoding json
service, which I can successfully pull into a jsonstore using similar code.
That response is in the format { "spatialReference" : { "wkid" : 4326 },
"candidates" : [ { ... } ] } ... and so I wonder if that {"featureTypes":
hanging off the front of the geoserver response is confusing something?)
If Firebug can see the correct response I should be able to pull it into my
javascript code. SOMEHOW. Even if it's just as a text string that I have to
parse. But I can't even figure out how to do that.
Any suggestions for how to deal with this?
Another possible work-around would be to test whether the current user is
logged in to geoserver. Can anyone point me to some sample javascript for how
to do that, preferably without a proxy?
(I'm currently testing my entire implementation on localhost, which is running
Windows 7. I've found references to setting up geoserver itself as a proxy,
but I don't think that will work as long as I'm on localhost.)
Kat
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users