2

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

asked Nov 13, 2014 at 12:11
1
  • Is your server running? What do you get when you put 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 Commented Nov 13, 2014 at 13:25

1 Answer 1

3

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.

answered Nov 13, 2014 at 19:25

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.