Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a problem with WFS request:

  var wfs = new OpenLayers.Layer.Vector("WFS",{                    
  strategies: [new OpenLayers.Strategy.Fixed()],
  projection: new OpenLayers.Projection("EPSG:4326"),
  protocol: new OpenLayers.Protocol.WFS({                          
  version: "1.1.0",
  url : "http://localhost:8080/geoserver/wfs",// 
  featureNS : "http://www.opengeospatial.net/cite", // workspace namespace URI                  
  geometryName: "geom",  // field in Feature Type details with type "Geometry"           
  featurePrefix: 'cite',    //geoserver workspace name
  featureType: "InfoGeometric"        //geoserver Layer Name                                                                                                    
}),

In particular in chrome console i have the error POST http:// localhost:8081/cgi-bin/proxy.cgi?url=http%3A%2F%2Flocalhost%3A8080%2Fgeoserver%2Fwfs 404 (Not Found). I have create in C:\Program Files\apache-tomcat-6.0.33\lib the folder cgi-bin and in it the file proxy.cgi (i added in allowedHosts variable values'localhost','localhost:8080','localhost:8081', 'localhost:8080/geoserver/wfs'). In OpenLayers.js i set OpenLayers.ProxyHost="/cgi-bin/proxy.cgi?url="; Now, if i go on http:// localhost:8080/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=cite:InfoGeometric i have a description in xml of my InfoGeometric but if i go on http:// localhost:8081/cgi-bin/proxy.cgi i don't connect to it. I don't know i must do. Thanks very much.

share|improve this question
    
do you have a second server running on port 8081? –  iant Oct 31 '12 at 6:36
    
no, tomcat on 8081 and geoserver on 8080. Two questions: 1) is corret OpenLayers.ProxyHost="/cgi-bin/proxy.cgi?url="? Must change it in OpenLayers.ProxyHost="xxx/cgi-bin/proxy.cgi?url=" since my application run on URL http:// localhost:8081/xxx/page.html? 2) The position of cgi-bin folder is corrent? Must i change its position in WEB-INF of my application? Thanks for future reply. –  Riccardo Oct 31 '12 at 8:19
add comment

1 Answer

You first need to configure Tomcat to run CGI scripts. I am assuming you are using the OpenLayers provided proxy.cgi file. This is a Python script so you are going to need to make sure that Python is installed.

To enable CGI in Tomcat you need to check the {CATALINA_HOME}/conf/web.xml and remove the comments from around the CGI servlet and servlet-mapping configuration elements.

You then need to set the configuration of the CGI servlet to match your system, for example the executable that will run the CGI script, the type of script (default is perl) etc.

The script itself should (by default) be placed in the WEB-INF/cgi folder of your web application root folder. This is the default setting but you can change it using the cgiPathPrefix configuration parameter. The Tomcat documentation page provides more details.

share|improve this answer
    
Hi CHenderson, thanks for your reply.I don't undestand a thing, my request is made in a js file (name.js) that load the openlayer map. This file is under the WebContent folder of my project. Why i must do this settings? Must i move name.js in WEB-INF/cgi? I'm very confused –  Riccardo Oct 31 '12 at 20:57
    
@Riccardo, the 404 error you are seeing is because the proxy.cgi file is not in the correct place. The Tomcat configuration will determine where the proxy.cgi file should go. /cgi-bin/proxy.cgi means it should be in the root of your Tomcat installation - creating the lib folder will not resolve that error. Have you tried putting the proxy.cgi file in the same directory as your web page? Remember that the url supplied to ProxyHost will be relative to your PAGE and not your JS files. Try OpenLayers.Proxyhost='proxy.cgi?url=' and put the file in the same place as your web page. –  CHenderson Nov 2 '12 at 12:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.