Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a layer that can be configured to render as WFS or WMS. I want to apply the same sld styling that I have defined in Geoserver to make it consistent. But when I try to get the SLD text from geoserver I get an empty text. I use the following code to get the style from geoserver:

void init()
{
   OpenLayers.Request.GET({
        url: "http://localhost:8080/geoserver/rest/styles/general.sld",
        success: complete
    });
}

function complete(req) {
    var format = new OpenLayers.Format.SLD();

    sld = format.read(req.responseXML || req.responseText);

    setLayerStyles();
}

The req.responseXML and req.responseText is always empty. However, if I copy the sld file locally and then try to do a get I will successfully get the text from the sld file.

If I try to open the link on the web browser using the geoserver sld link then the browser attempts to download the file instead of viewing it. This could be the reason why the text returned is empty. If I try to open the sld link locally that I copied across from geoserver then the file would open up in the web browser.

Any one know how to solve this?

share|improve this question
1  
you'll need a proxy - see numerous other questions –  iant Apr 3 '13 at 13:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.