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.
Sending request to the WMS Service by appending "?service=WMS&request=GetCapabilities".
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.
<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.