I want to use external SLD file in my OpenLayers application. So I created WMS layer like this:
var ly= new OpenLayers.Layer.WMS("mylyer",
serverurl,
{
layers: "PGS:geopoint",
transparent:true,
style:"",
sld: "http://localhost/app/style/point.xml"
},
{
isBaseLayer: false,
buffer:0
});
This is not working. This is returning null images. If I send request from browser (not openlayers) it returns error:
java.net.ConnectException: Connection refused Connection refused
1 Answer 1
http://localhost/
will be interpreted by the WMS server as its own host, but the SLD you want to use is on your app's host (let's say http://myapp.com/
. So yo will have to change your SLD URL to the app's public URL (using its FQDN), e.g. http://myapp.com/style/point.xml
:
{
layers: "PGS:geopoint",
transparent:true,
style:"",
sld: "http://myapp.com/style/point.xml/point.xml"
},
Depending on your WMS implementation, there may be a shortcut if both the WMS and the app run on the same host, e.g. a relative URL or a file URL, but using the FQDN of the app host is the safest way to go.
http://localhost/app/style/point.xml
into your browser address bar? Is it different if you add a port, like this:http://localhost:8080/app/style/point.xml