Unable to add WMS Service to Map.

3155
1
06-30-2014 04:58 AM
VivekPrasad
Occasional Contributor
Hi Everyone,

I am trying to add a WMS service to map. The functionality is to add any WMS service to map by using the url provided by user.

I am facing various errors as below.

Before starting with the issue, I would like to explain the procedure I am following to create and add a WMS Service.

Steps:

1. Sending request to WMS service as below, to run "GetCapabilities" task.

  1. Sending request to the WMS Service by appending "?service=WMS&request=GetCapabilities".

  2. To send request I am using "dojo/request"; "dojo/request/xhr", "esri/request" and also tried with XMLHttpRequest

At this stage, i am getting correct response only in IE. In Chrome and FireFox i am getting errors as below.

Mozilla: 407 Proxy Authentication required.

Chrome: No "Access-Control-Allow-Origin" header is present on the requested resource. Origin 'http:localhost:<port>' is therefore not allowed access.

IE: works fine.

2. From the response of the above request, I am constructing, an array for VisibleLayers and creating object for the WMS Layer as below..

var wmsLayer = new WMSLayer(wmsUrl, {
                visibleLayers: visibleLayersArray
            });

and adding it to the map.

3. I attached "layer-add-result" event to map to zoom to the layer when the layer is added.
For some services, in this event, i am getting "error" in evt object. saying "GetCapabilities" request is failed. (I am using Proxy page)

4. And for some layers, there is no error object in evt object. However, nothing is visible on map. When i am panning or zooming and observed the req/response in fiddler and got the below error.

[HTML]
<?xml version="1.0" encoding="ISO-8859-1"?>

-<ServiceExceptionReport xsi:schemaLocation="http://www.opengis.net/ogc http://schemas.opengis.net/wms/1.3.0/exceptions_1_3_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/ogc" version="1.3.0">

<ServiceException code="LayerNotDefined"> msWMSLoadGetMapParams(): WMS server error. Invalid layer(s) given in the LAYERS parameter. A layer might be disabled for this request. Check wms/ows_enable_request settings. </ServiceException>

</ServiceExceptionReport>
[/HTML]


Could some one please help me in solving this. I don't want to use resourceInfo object.

Thanks in advance!
0 Kudos
1 Reply
VivekPrasad
Occasional Contributor
Hi,

I could fix this issue.
0 Kudos