[mapserver-users] C# mapscripts and WFS Service , xml-encoded Post Request with openlayers

Fuming Li wingicelee at hotmail.com
Sun Sep 12 20:37:15 PDT 2010


I got a walkaround to address this issue by trying. Here is the solution: instead of using loadparams(), just assign the querystring in the post request to OWSRequest. 
It worked. :-)

 public void ProcessRequest (HttpContext context) {
        try
        {
            OWSRequest req = new OWSRequest();
            System.Collections.Specialized.NameValueCollection queryStr = context.Request.QueryString;
            for (int i = 0; i < queryStr.Count; ++i) req.setParameter(queryStr.GetKey(i), queryStr.Get(i));
         
            if (context.Request.HttpMethod == "POST")
            {
                StreamReader reader = new StreamReader(context.Request.InputStream, context.Request.ContentEncoding);  //System.Text.Encoding.UTF8
                String sXMLRequest = reader.ReadToEnd();
                req.type = MS_REQUEST_TYPE.MS_POST_REQUEST;
                req.postrequest = sXMLRequest;
            }
  ...





Date: Fri, 10 Sep 2010 09:36:04 +0200
Subject: Re: [mapserver-users] C# mapscripts and WFS Service , xml-encoded Post Request with openlayers
From: szekerest at gmail.com
To: wingicelee at hotmail.com
CC: mapserver-users at lists.osgeo.org

Hi,

Currently loadParams can only be called within the context of a CGI process and it may not be usable ny an ASP.NET application. However I'll inversigate the approach whether it could be made suitable for use in ASP.NET environment too.


Best regards,

Tamas



2010/9/10 Fuming Li <wingicelee at hotmail.com>






Hi, I 'm currently deploying a WFS Server with C# mapscripts.  The 
Request issued by openlayers is xml-encoded post request.

When I 
tried to use "loadparam", it exited abnormally.  So I had to parse 
parameter by myself.  So my question is: do I have to parse the 
xml-encoded post request manually?

is there a function I can use to 
parse the post request?



WFS Service:



public class MapWFS : IHttpHandler {

   

    public void ProcessRequest 
(HttpContext context) {

        try

        {

            OWSRequest req = 
new OWSRequest();



            
System.Collections.Specialized.NameValueCollection queryStr = 
context.Request.Params;



            
//req.loadParams();  can't call this function, it will exit immediately.

            
req.setParameter("service", "WFS");

            
req.setParameter("version", "1.0.0");

            
req.setParameter("request", "getFeature");

 

            for (int i = 0; i 
< queryStr.Count; ++i)

            {

                
req.setParameter(queryStr.GetKey(i), queryStr.Get(i));

           }

            

            string mapFileName =
 ConfigurationManager.AppSettings["MapFilePath"];

            mapObj map = new 
mapObj(context.Server.MapPath(mapFileName));

    ...

            

            
mapscript.msIO_installStdoutToBuffer();



            
map.OWSDispatch(req);



            
context.Response.ContentType = 
mapscript.msIO_stripStdoutBufferContentType();

            
context.Response.BinaryWrite(mapscript.msIO_getStdoutBufferBytes());

            
mapscript.msIO_resetHandlers();



OpenLayers:

            var wfs = new 
OpenLayers.Layer.Vector("WFSCELL", {

                    strategies:
 [new OpenLayers.Strategy.BBOX()],

                    
isBaseLayer: true,

                    styleMap: 
styleMap,

                    service: 
wfs,

                    Version: 
"1.0.0",

                    
TypeName:"cell",

                    protocol: 
new OpenLayers.Protocol.WFS({

                        url: 
"MapWFS.ashx",

                        
featureType: "cell",

                        
featurePrefix: "cs" ,

                        
featureNS: "http://www.openplans.org/topp",

                        
geometryName: 'msGeometry'





                    })

                });

        wfs.isBaseLayer = true;

        map.addLayer(wfs);





content of the post-request:

  

<wfs:GetFeature xmlns:wfs="http://www.opengis.net/wfs" 
service="WFS" version="1.0.0" 
xsi:schemaLocation="http://www.opengis.net/wfs 
http://schemas.opengis.net/wfs/1.0.0/WFS-transaction.xsd" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

    <wfs:Query typeName="cs:cell" 
xmlns:cosunet="http://www.openplans.org/topp">

          <ogc:Filter xmlns:ogc="http://www.opengis.net/ogc">

               <ogc:BBOX>

                   
<ogc:PropertyName>msGeometry</ogc:PropertyName>

                   <gml:Box xmlns:gml="http://www.opengis.net/gml" 
srsName="EPSG:4326"><gml:coordinates decimal="." cs="," ts=" 
">110.298828125,28.1875 
127.701171875,33.8125</gml:coordinates></gml:Box>

               </ogc:BBOX>

          </ogc:Filter>

</wfs:Query>

  

  

  

</wfs:GetFeature>



From: wingicelee at hotmail.com
To: mapserver-users at lists.osgeo.org
Date: Thu, 9 Sep 2010 00:44:30 +0000

Subject: [mapserver-users] C# mapscripts and WFS Service , xml-encoded Post Request with openlayers








Hi, I 'm currently deploying a WFS Server with C# mapscripts.  The Request issued by openlayers is xml-encoded post request.
When I tried to use "loadparam", it exited abnormally.  So I had to parse parameter by myself.  So my question is: do I have to parse the xml-encoded post request manually?

is there a function I can use to parse the post request?


Thanks and Best Request,
William

 		 	   		  

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

_______________________________________________

mapserver-users mailing list

mapserver-users at lists.osgeo.org

http://lists.osgeo.org/mailman/listinfo/mapserver-users



SZZSZZSZZSZZSZZ 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20100913/463b92a0/attachment.htm>


More information about the MapServer-users mailing list