3

I want to take capabilities from tomcat's geoserver, using this code:

wms = new OpenLayers.Format.WMSCapabilities();
OpenLayers.Request.GET({
    url:"http://localhost:8080/geoserver/wms/filedata?request=GetCapabilities",
    success: function(e){
        var response = wms.read(e.responseText);
var capability = response.capability;
for (var i=0, len=capability.layers.length; i<len; i+=1) {
    var layerObj = capability.layers[i];
    if (layerObj.name === 'filedata') {
        map.zoomToExtent(OpenLayers.Bounds.fromArray(layerObj.llbbox));
        break;
    }
}
    }
});

But firebug says that "capability is not defined" in this string:

for (var i=0, len=capability.layers.length; i<len; i+=1) {

If I write the url from capability request in a browser, I get the error:

XML Parsing Error: XML or text declaration not at start of entity
Adress: http://localhost:8080/geoserver/wms/filedata?request=GetCapabilities
Line number 5091, column 21:          <Abstract><?xml version="1.0" encoding="UTF- 8"?>
<ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://www.opengis.net/ogc http://localhost:8080/
geoserver/schemas/wms/1.3.0/exceptions_1_3_0.xsd">   <ServiceException>
--------------------^

But if I look in firebug, I can see that application got the capabilities.

In standalone Geoserver all works fine.

2
  • can you try to get your localhost:8080/geoserver. is it ok? or is there any error?
    – urcm
    May 22, 2012 at 7:17
  • yes, i can see Geoserver on this url, its ok.
    – Kliver Max
    May 22, 2012 at 7:43

1 Answer 1

4

Service parameter is mandatory for making requests to WMS services. Your URL should looks like:

http://localhost:8080/geoserver/wms/filedata?request=GetCapabilities&service=WMS
3
  • it not work too.
    – Kliver Max
    May 22, 2012 at 7:50
  • I find the error. If someone interest. Problem was in one of tomcat's geoserver standart layer. In capabilities was error text. javax.xml.transform.TransformerExeption: Translator error Translator error Error occurred trying to write out metadata for layer: Pk50095 Unable to acquire a reader for this coverage with format: WorldImage Have no idea why it happening. But when im delete this layer all start work fine. Tnx for your answers.
    – Kliver Max
    May 22, 2012 at 8:17
  • 2
    It's a known issue: jira.codehaus.org/browse/GEOS-4544
    – unicoletti
    May 22, 2012 at 9:51

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.