Chrome, WMS and content-type application/vnd.ogc.wms_xml fails..

3203
4
12-03-2013 11:54 PM
EndreStokseth
New Contributor
I'm using Esri js api 3.7 and "esri/layers/WMSLayer" to add WMS layers to my map.

The WMS GetCapabilities response has content-type application/vnd.ogc.wms_xml (from MapServer).
In Chrome (v. 31.x) the xhr object returns null, and not the xml document. It works fine in FireFox. So the capability xml file is not loaded, and the wms does not show up in the map.

It seems like Chrome does not handle the response as text/xml, and instead returns null.
If I change the response content-type from application/vnd.ogc.wms_xml to text/xml (using Fiddler), it also works in Chrome.

Has anyone else have experiences this?

I have found 2 workarounds:
1) Create an resourceInfo object(optional parameter in creating wms layer). This prevents the GetCapabilities request.
    There are many services and layers, so this is not an prefered option..
2) Use my own old custom WMS-layer object(inherit esri/layers/TiledMapServiceLayer). It does not ask for GetCapabilities.

Any other tips/workarounds?
Should the Esri js api handle this?


-Endre
0 Kudos
4 Replies
DavidElies
New Contributor III
Hi,

I have the exact same problem.  The service I'm accessing is the public NOAA nowCOAST mapping service:

http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs

It returns its responses using Content-Type: application/vnd.ogc.wms_xml

The layers work in IE and Firefox, but in chrome, I get the error message:

"GetCapabilities request for http://nowcoast.noaa.gov/wms/com.esri.wms.Esrimap/obs failed. (Response is null.)"

This is very frustrating.  The only workaround we have right now is to manually create an ajax request, parse the data and create a matching resource info object.  I don't want to have to do this.  Does anybody have a solution for this problem?

Thanks!
0 Kudos
AlejandroGonzález_Santiuste
New Contributor
Did you solve it? I have a similar problem. But in my case depends on the size of the wms, i think..

Galicia: This one contains WMS from Galicia (north of Spain) and it loads correctly on Firefox and Chrome. Right

http://signo-geo.com/alejandrowms/mapacorrecto2.html

Andalucia (south of Spain): Here is the problem, because the WMS on Chrome is not loading and I don't know why but in Firefox it works fine.

http://signo-geo.com/alejandrowms/mapaprueba2.html

Thanks!
0 Kudos
by Anonymous User
Not applicable
I just encountered this problem as well, and fortunately found this thread that clarified what the cause was. Since I need to use a proxy for the GetCapabilities request, I've just edited the proxy so that a ContentType of 'application/vnd.ogc.wms_xml' with 'text/xml' before the response is returned.

If you're using the current DotNet version of the resource-proxy Esri has hosted on GitHub (https://github.com/Esri/resource-proxy), you can make this change near the start of the fetchAndPassBackToClient method in the proxy.ashx file (around line 293):

private bool fetchAndPassBackToClient(System.Net.WebResponse serverResponse, HttpResponse clientResponse, bool ignoreAuthenticationErrors) {
        if (serverResponse != null) {
            if (serverResponse.ContentType == "application/vnd.ogc.wms_xml") clientResponse.ContentType = "text/xml";
 else clientResponse.ContentType = serverResponse.ContentType;
            using (Stream byteStream = serverResponse.GetResponseStream()) {
            ....
0 Kudos
VivekPrasad
Occasional Contributor
I just encountered this problem as well, and fortunately found this thread that clarified what the cause was. Since I need to use a proxy for the GetCapabilities request, I've just edited the proxy so that a ContentType of 'application/vnd.ogc.wms_xml' with 'text/xml' before the response is returned. 

If you're using the current DotNet version of the resource-proxy Esri has hosted on GitHub (  https://github.com/Esri/resource-proxy), you can make this change near the start of the fetchAndPassBackToClient method in the proxy.ashx file (around line 293): 

private bool fetchAndPassBackToClient(System.Net.WebResponse serverResponse, HttpResponse clientResponse, bool ignoreAuthenticationErrors) {
        if (serverResponse != null) {
            if (serverResponse.ContentType == "application/vnd.ogc.wms_xml") clientResponse.ContentType = "text/xml";
 else clientResponse.ContentType = serverResponse.ContentType;
            using (Stream byteStream = serverResponse.GetResponseStream()) {
            ....



Thanks Mike!

It helped me a lot!
0 Kudos