<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>An update. </div>
<div><br>
</div>
<div>ESRI has decided not to follow the standard and has closed the bug, NIM104744, we submitted about not decoding a plus symbol ‘+’ to a space. Their solution is for everyone else to encode all spaces as %20 and to ignore http://tools.ietf.org/html/rfc3986.
They have closed the bug and listed it as a known limit.</div>
<div><br>
</div>
<div>http://support.esri.com/en/bugs/nimbus/TklNMTA0NzQ0</div>
<div><br>
</div>
<div>So, in order for Mapserver to consume ESRI WMS services, with spaces in the name, the spaces have to be encoded as %20. </div>
<div><br>
</div>
<div>I see Mapserver 7.0 still encodes spaces to a ‘+’, so I thought people should know if they intend to consume any ESRI WMS layers with spaces in the name. </div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Paul Moen <<a href="mailto:pmoen@nd.gov">pmoen@nd.gov</a>><br>
<span style="font-weight:bold">Date: </span>Wednesday, August 20, 2014 at 9:43 AM<br>
<span style="font-weight:bold">To: </span>"Lime, Steve D (MNIT)" <<a href="mailto:Steve.Lime@state.mn.us">Steve.Lime@state.mn.us</a>>, "<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a>" <<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a>><br>
<span style="font-weight:bold">Subject: </span>Re: [mapserver-users] WMS request fails when spaces are encoded as plus symbol in query part of URL<br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>Steve,</div>
<div><br>
</div>
<div>You are right about the outcome of 1 and 2. 1 encodes the % and 2 throws the following error.</div>
<div><br>
</div>
<div>msBuildWMSLayerURLBase(): One of wms_onlineresource, wms_server_version, wms_name metadata is missing in layer USGS DRG 250k Topo Maps. Please either provide a valid CONNECTION URL, or provide those values in the layer's metadata.\n\n</div>
<div><br>
</div>
<div>I found the function as you said and </div>
<div>I removed the </div>
<div><br>
</div>
<div>
<div> if (*i == ' ')</div>
<div> *j = '+';</div>
<div> else </div>
</div>
<div>from the function then recompiled.</div>
<div><br>
</div>
<div>
<blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;">
<div>char *msEncodeUrlExcept(const char *data, const char except)</div>
<div>{</div>
<div> char *hex = "0123456789ABCDEF";</div>
<div> const char *i;</div>
<div> char *j, *code;</div>
<div> int inc;</div>
<div> unsigned char ch;</div>
<div><br>
</div>
<div> for (inc=0, i=data; *i!='\0'; i++)</div>
<div> if (msEncodeChar(*i))</div>
<div> inc += 2;</div>
<div><br>
</div>
<div> code = (char*)msSmallMalloc(strlen(data)+inc+1);</div>
<div><br>
</div>
<div> for (j=code, i=data; *i!='\0'; i++, j++) {</div>
<div> if ( except != '\0' && *i == except ) {</div>
<div> *j = except;</div>
<div> } else if (msEncodeChar(*i)) {</div>
<div> ch = *i;</div>
<div> *j++ = '%';</div>
<div> *j++ = hex[ch/16];</div>
<div> *j = hex[ch%16];</div>
<div> } else</div>
<div> *j = *i;</div>
<div> }</div>
<div> *j = '\0';</div>
<div><br>
</div>
<div> return code;</div>
<div>}</div>
</blockquote>
</div>
<div><br>
</div>
<div>Everything works again after a mapserver recompile, install and finally a restart of apache. Thanks so much for the path to the solution.</div>
<div><br>
</div>
<div><span class="Apple-style-span" style="font-family: Calibri;">Paul Moen</span><span class="Apple-style-span" style="font-family: Calibri;"><br>
</span><span class="Apple-style-span" style="font-family: Calibri;"><a href="mailto:pmoen@nd.gov" target="_blank" style="color: blue;">pmoen@nd.gov</a></span><span class="Apple-style-span" style="font-family: Calibri;"><br>
</span><span class="Apple-style-span" style="font-family: Calibri;">701-328-2434</span></div>
</div>
<div><span class="Apple-style-span" style="font-family: Calibri;"><br>
</span></div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:11pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span><Lime>, "Steve D (MNIT)" <<a href="mailto:Steve.Lime@state.mn.us">Steve.Lime@state.mn.us</a>><br>
<span style="font-weight:bold">Date: </span>Wednesday, August 20, 2014 at 12:41 AM<br>
<span style="font-weight:bold">To: </span>Paul Moen <<a href="mailto:pmoen@nd.gov">pmoen@nd.gov</a>>, "<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a>" <<a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a>><br>
<span style="font-weight:bold">Subject: </span>RE: [mapserver-users] WMS request fails when spaces are encoded as plus symbol in query part of URL<br>
</div>
<div><br>
</div>
<div dir="ltr"><style type="text/css" id="owaParaStyle"></style>
<div style="word-wrap:break-word" fpstyle="1" ocsi="0">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">
<div style="direction: ltr;">
<div><font size="3" style="color: rgb(0, 0, 0);">Hmmm... Nice backwards compatibility ESRI. The +'s seem to still be quite legal (</font><font size="3"><a href="http://tools.ietf.org/html/rfc3986" target="_blank">http://tools.ietf.org/html/rfc3986</a> and other
references) in the query string (but not the path). I don't have access to test and I'm guessing these ideas won't work but they might be worth a quick try:</font></div>
<div style="color: rgb(0, 0, 0);"><font size="3"><br>
</font></div>
<div style="color: rgb(0, 0, 0);"><font size="3"> 1) Try encoding the wms_name in the metadata: "wms_name" "Topomap%20DRG%20250k"</font></div>
<div style="color: rgb(0, 0, 0);"><font size="3"> 2) Don't set the wms_name in the metadata but add it to the connection: CONNECTION "<a href="http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?LAYERS=Topomap%20DRG%20250k&">http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?LAYERS=Topomap%20DRG%20250k&</a>"</font></div>
<div style="color: rgb(0, 0, 0);"><font size="3"><br>
</font></div>
<div><font size="3" style="color: rgb(0, 0, 0);">I'm betting MapServer will encode the %'s in 1 and throw an error in 2. Otherwise you could hack the MapServer source. Function is called msEncodeUrlExcept() in mapstring.c you can see the section to change starting
at line 1138 in git master (</font><font size="3"><a href="https://github.com/mapserver/mapserver/blob/master/mapstring.c)." target="_blank">https://github.com/mapserver/mapserver/blob/master/mapstring.c)</a></font></div>
<div style="color: rgb(0, 0, 0); font-family: Tahoma; font-size: 10pt;"><font size="3"><br>
</font></div>
<div style="color: rgb(0, 0, 0); font-family: Tahoma;"><font size="3">Maybe it's worth making this change as part of 7.0?</font></div>
<div style="color: rgb(0, 0, 0); font-family: Tahoma;"><font size="3"><br>
</font></div>
<div style="color: rgb(0, 0, 0); font-family: Tahoma;"><font size="3">Steve</font></div>
<div style="color: rgb(0, 0, 0); font-family: Tahoma; font-size: 10pt;"><font size="3"><br>
</font></div>
<br>
<div style="color: rgb(0, 0, 0); font-family: 'Times New Roman'; font-size: 16px;">
<hr tabindex="-1">
<div id="divRpF434791" style="direction:ltr"><font face="Tahoma" size="2" color="#000000"><b>From:</b><a href="mailto:mapserver-users-bounces@lists.osgeo.org">mapserver-users-bounces@lists.osgeo.org</a> [<a href="mailto:mapserver-users-bounces@lists.osgeo.org">mapserver-users-bounces@lists.osgeo.org</a>]
on behalf of Moen, Paul T. [<a href="mailto:pmoen@nd.gov">pmoen@nd.gov</a>]<br>
<b>Sent:</b> Tuesday, August 19, 2014 4:56 PM<br>
<b>To:</b> <a href="mailto:mapserver-users@lists.osgeo.org">mapserver-users@lists.osgeo.org</a><br>
<b>Subject:</b> [mapserver-users] WMS request fails when spaces are encoded as plus symbol in query part of URL<br>
</font><br>
</div>
<div></div>
<div>
<div>Hi all,</div>
<div><br>
</div>
<div>We are consuming WMS services hosted by ESRI ArcGIS Server 10.0. The server was upgraded to ArcGIS Server 10.2.2 and we no longer can access layer names with spaces.</div>
<div><br>
</div>
<div>This is the server’s capabilities.</div>
<div><a href="http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?request=GetCapabilities&service=WMS">http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?request=GetCapabilities&service=WMS</a></div>
<div><br>
</div>
<div>This is the layer I am using.</div>
<div><br>
</div>
<div>
<div>LAYER</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span># DEBUG 5</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>CONNECTIONTYPE WMS</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>CONNECTION "<a href="http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?">http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?</a>"</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>METADATA</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>"wms_name" "Topomap DRG 250k"</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>"wms_format" "image/png"</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>"wms_server_version" "1.1.1"</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>"wms_srs" "EPSG:2266"</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>END</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>TYPE RASTER</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>STATUS OFF</div>
<div><span class="Apple-tab-span" style="white-space:pre"></span>NAME "USGS DRG 250k Topo Maps"</div>
<div>END</div>
</div>
<div><br>
</div>
<div>Mapserver encodes this request as follows. Notice that the layer name, which is ‘Topomap DRG 250k’, is encoded with the spaces becoming the ‘+’ character.</div>
<div><br>
</div>
<div><a href="http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?LAYERS=Topomap+DRG+250k&REQUEST=map&WMTVER=1.0.0&SERVICE=WMS&FORMAT=image/png&STYLES=&HEIGHT=1146&SRS=EPSG:2266&WIDTH=1271&BBOX=1906240.15992838,596656.333359479,2119730.85012732,789150.692893686&TRANSPARENT=TRUE&EXCEPTIONS=INIMAGE">http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?LAYERS=Topomap+DRG+250k&REQUEST=map&WMTVER=1.0.0&SERVICE=WMS&FORMAT=image/png&STYLES=&HEIGHT=1146&SRS=EPSG:2266&WIDTH=1271&BBOX=1906240.15992838,596656.333359479,2119730.85012732,789150.692893686&TRANSPARENT=TRUE&EXCEPTIONS=INIMAGE</a></div>
<div><br>
</div>
<div>This returns the error in an image that says “Parameter ‘layers’ contains unacceptable layer names.”</div>
<div><br>
</div>
<div>When I replace the + in the layer name with %20, LAYERS=Topomap+DRG+250k become LAYERS=Topomap%20DRG%20250k and the request becomes the following.</div>
<div><br>
</div>
<div><a href="http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?LAYERS=Topomap%20DRG%20250k&REQUEST=map&WMTVER=1.0.0&SERVICE=WMS&FORMAT=image/png&STYLES=&HEIGHT=1146&SRS=EPSG:2266&WIDTH=1271&BBOX=1906240.15992838,596656.333359479,2119730.85012732,789150.692893686&TRANSPARENT=TRUE&EXCEPTIONS=INIMAGE">http://ndgishub.nd.gov/arcgis/services/All_Elevation/MapServer/WMSServer?LAYERS=Topomap%20DRG%20250k&REQUEST=map&WMTVER=1.0.0&SERVICE=WMS&FORMAT=image/png&STYLES=&HEIGHT=1146&SRS=EPSG:2266&WIDTH=1271&BBOX=1906240.15992838,596656.333359479,2119730.85012732,789150.692893686&TRANSPARENT=TRUE&EXCEPTIONS=INIMAGE</a></div>
<div><br>
</div>
<div>That request works. Obviously, ESRI is no longer decoding + as a space and therefore does not recognize the layer name with spaces. </div>
<div><br>
</div>
<div>Is there any way I can have mapserver encode all characters using percent-encoding, or at least encode spaces as %20 instead of a + character.</div>
<div><br>
</div>
<div>Thanks,</div>
<div>
<div>
<div><br>
</div>
<span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; border-spacing: 0px;"><span class="Apple-style-span" style="font-family:Calibri,sans-serif; font-size:14px"><span class="Apple-style-span" style="font-family:Calibri">Paul
Moen</span><span class="Apple-style-span" style="font-family:Calibri"><br>
</span><span class="Apple-style-span" style="font-family:Calibri"><a href="mailto:pmoen@nd.gov" style="color:blue" target="_blank">pmoen@nd.gov</a></span><span class="Apple-style-span" style="font-family:Calibri"><br>
</span><span class="Apple-style-span" style="font-family:Calibri">701-328-2434</span></span><br>
<br>
</span></div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</span></div>
</div>
</span>
</body>
</html>