[mapserver-users] MapScript issue in multiple WCF apps (ASP.NET)

Brian Poteat Poteat.Brian at geoeye.com
Wed Mar 9 09:17:55 EST 2011


Thanks Tamas,
I put together a solution that mimics what I am doing at a very simple level and I got it to error fairly easily.

This zip contains an example mapfile and the solution used to reproduce the setup. I just put everything in c:\tmp\test. The applications are .NET 4.0 WCF endpoints and will install as IIS web services (so obviously you’ll need the appropriate software to build/run).
http://dl.dropbox.com/u/649621/WcfMapScript.zip

If you build the solution and then execute the following service requests in order, at some point the requests no longer return correct data. Asking for one layer will return the other. Sometimes the results vary but usually just mixing up the requested layers on the two different services will cause strange behavior.

http://localhost/MapScriptService/MapScriptService.svc/ms?mapfile=C:\tmp\test\map.map&LAYERS=L54&CRS=EPSG:4326&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fpng&BBOX=60.999933182566,24.9997419977717,73.0167274,30.0446813&WIDTH=1032&HEIGHT=358

http://localhost/MapScriptService2/MapScriptService.svc/ms?mapfile=C:\tmp\test\map.map&LAYERS=L57&CRS=EPSG:4326&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fpng&BBOX=60.999933182566,24.9997419977717,73.0167274,30.0446813&WIDTH=1032&HEIGHT=358

http://localhost/MapScriptService/MapScriptService.svc/ms?mapfile=C:\tmp\test\map.map&LAYERS=L57&CRS=EPSG:4326&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fpng&BBOX=60.999933182566,24.9997419977717,73.0167274,30.0446813&WIDTH=1032&HEIGHT=358

http://localhost/MapScriptService2/MapScriptService.svc/ms?mapfile=C:\tmp\test\map.map&LAYERS=L54&CRS=EPSG:4326&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&STYLES=&EXCEPTIONS=application%2Fvnd.ogc.se_inimage&FORMAT=image%2Fpng&BBOX=60.999933182566,24.9997419977717,73.0167274,30.0446813&WIDTH=1032&HEIGHT=358

I apologize for the strange requests and images but I am a not really familiar with the mapfile format and just tried to reproduce the requests as closely as they were in a real environment.
Brian

From: Tamas Szekeres [mailto:szekerest at gmail.com]
Sent: Tuesday, March 08, 2011 4:46 PM
To: Brian Poteat
Cc: mapserver-users at lists.osgeo.org
Subject: Re: [mapserver-users] MapScript issue in multiple WCF apps (ASP.NET)

Hi Brian,

Could you provide the sequence of the requests, a mapfile example, that can be used to reproduce this problem?
What do you mean by "configure them independently"? Different application pool for each service type?

Best regards,

Tamas


2011/3/8 Brian Poteat <Poteat.Brian at geoeye.com<mailto:Poteat.Brian at geoeye.com>>
I have a very strange issue while using MapScript from within some web service projects. I have different projects/applications for different services – one for each of WCF, WMS, WFS, and WMTS – so we can configure them independently. MapScript requests work fine for all of them separately but if I access MapScript from one and then another, one of them will not work correctly anymore. The requests will return success (result == 0) and the format returned is correct but the data is either null or an incorrect image. It doesn’t seem to be a threading issue since I can bombard any one of the services with asynchronous requests and they are handled fine and the problems don’t necessarily come while using the different applications at the same time – just one then the other.

I am using a support project for making the MS requests that is referenced by each application (though I tried putting the code directly in each app with the same results). Below is a simplified version of the helper utility I am using. Is there anything that stands out as being an obvious issue? My endpoint applications simply get the query parameters from the url request and pass them as the requestParams argument with the appropriate map file.
namespace MapScript
{
         public class MapScriptResponse
         {
                 public string Format { get; set; }
                 public byte[] Data { get; set; }
                 public string ErrorString { get; set; }
                 public DateTime LastModified { get; set; }
         }
         public class MapScriptUtilities
         {
                 /// <summary>
                 /// Execute a service request to mapserver through mapscript
                 /// </summary>
                  /// <param name="mapFile">Physical path to the map file on which to make the request</param>
                 /// <param name="requestParams">List of request parameters</param>
                 /// <returns>The response from mapscript.</returns>
                  public static MapScriptResponse ServiceRequest(string mapFile, Dictionary<string, string> requestParams)
                 {
                          MapScriptResponse response = new MapScriptResponse();
                          mapObj map = new mapObj(mapFile);
                          OWSRequest owsRequest = new OWSRequest();
                          Dictionary<string, string>.Enumerator en = requestParams.GetEnumerator();
                          string paramName = "";
                          string paramValue = "";
                          while (en.MoveNext())
                          {
                                   paramName = en.Current.Key;
                                   paramValue = en.Current.Value;
                                   owsRequest.setParameter(paramName, paramValue);
                          }
                          mapscript.msIO_installStdoutToBuffer();
                          int resultCode = map.OWSDispatch(owsRequest);
                          if (resultCode == 0)
                          {
                                   response.Format = mapscript.msIO_stripStdoutBufferContentType();
                                   response.Data = mapscript.msIO_getStdoutBufferBytes();
                          }

                          return response;
                 }
         }
}

Any help would be greatly appreciated.
Brian

_______________________________________________
mapserver-users mailing list
mapserver-users at lists.osgeo.org<mailto:mapserver-users at lists.osgeo.org>
http://lists.osgeo.org/mailman/listinfo/mapserver-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapserver-users/attachments/20110309/e1f9bff0/attachment-0001.html


More information about the mapserver-users mailing list