WFS OpenLayers.ProxyHost Tomcat 5.5

3 messages Options
Embed this post
Permalink
stash

WFS OpenLayers.ProxyHost Tomcat 5.5

Reply Threaded More More options
Print post
Permalink
Hello,
I want so show my map with a OpenLayers.Layer.WFS. Therefore I did the same as in the openlayers examples to show data with a WFS. But in my case, it doesn't work.

After some reading in the internet i found out, that I have to configure a OpenLayers.ProxyHost to show the data with a WFS.

In the examples I always found this type of code: OpenLayers.ProxyHost="/proxy/?url=";

What does that mean? Furthermore I found out, that I have to configure more, when I use Tomcat.

In my case I use a Server with Tomcat 5.5 installed and Geoserver to connect to WFS

http://IP:PORT/geoserver/wfs

What do I have to configure that I can show my data on Map over WFS.

(Sorry for my english, it is not the best)

Regards
stash
Mario Nuñez Jimenez

Re: WFS OpenLayers.ProxyHost Tomcat 5.5

Reply Threaded More More options
Print post
Permalink

Hello,
yes you need to configure a proxy. I have done it with Apache2 that supports cgi technology, but I don’t know how to do it with tomcat.

OpenLayers.ProxyHost="/proxy/?url=";
This code line is to locate the proxy.cgi so you have to put there the relative path to your proxy.cgi file.


There is an example in OL website anyway you should use an example of proxy.cgi like this one: (notice that allowed hosts is a list of reachable servers where you have to include your WMS URL or simply your server URL)


#!/usr/bin/env python


"""This is a blind proxy that we use to get around browser
restrictions that prevent the Javascript from loading pages not on the
same server as the Javascript.  This has several problems: it's less
efficient, it might break some sites, and it's a security risk because
people can use this proxy to browse the web and possibly do bad stuff
with it.  It only loads pages via http and https, but it can load any
content type. It supports GET and POST requests."""

import urllib2
import cgi
import sys, os

# Designed to prevent Open Proxy type stuff.

allowedHosts = ['www.openlayers.org', 'openlayers.org',
                'labs.metacarta.com', 'world.freemap.in',
                'prototype.openmnnd.org', 'geo.openplans.org',
                'sigma.openplans.org', 'demo.opengeo.org',
                'www.openstreetmap.org', 'sample.avencia.com',
                'http://view.atdmt.com', 'http://live.com']

method = os.environ["REQUEST_METHOD"]

if method == "POST":
    qs = os.environ["QUERY_STRING"]
    d = cgi.parse_qs(qs)
    if d.has_key("url"):
        url = d["url"][0]
    else:
        url = "http://www.openlayers.org"
else:
    fs = cgi.FieldStorage()
    url = fs.getvalue('url', "http://www.openlayers.org")

try:
   host = url.split("/")[2]
    if allowedHosts and not host in allowedHosts:
        print "Status: 502 Bad Gateway"
        print "Content-Type: text/plain"
        print
        print "This proxy does not allow you to access that location (%s)." % (host,)
        print
        print os.environ

    elif url.startswith("http://") or url.startswith("https://"):

        if method == "POST":
            length = int(os.environ["CONTENT_LENGTH"])
            headers = {"Content-Type": os.environ["CONTENT_TYPE"]}
            body = sys.stdin.read(length)
            r = urllib2.Request(url, body, headers)
            y = urllib2.urlopen(r)
        else:
            y = urllib2.urlopen(url)

        # print content type header
        i = y.info()
        if i.has_key("Content-Type"):
            print "Content-Type: %s" % (i["Content-Type"])
        else:
            print "Content-Type: text/plain"
        print

        print y.read()

        y.close()
    else:
        print "Content-Type: text/plain"
        print
        print "Illegal request."

except Exception, E:
    print "Status: 500 Unexpected Error"
    print "Content-Type: text/plain"
    print
    print "Some unexpected error occurred. Error text was:", E
------------------------------------------------------------------
This e-mail and the documents attached are confidential and intended
solely for the addressee; it may also be privileged. If you receive
this e-mail in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin
group liability cannot be triggered for the message content. Although
the sender endeavours to maintain a computer virus-free network,
the sender does not warrant that this transmission is virus-free and
will not be liable for any damages resulting from any virus transmitted.

Este mensaje y los ficheros adjuntos pueden contener informacion confidencial
destinada solamente a la(s) persona(s) mencionadas anteriormente
pueden estar protegidos por secreto profesional.
Si usted recibe este correo electronico por error, gracias por informar
inmediatamente al remitente y destruir el mensaje.
Al no estar asegurada la integridad de este mensaje sobre la red, Atos Origin
no se hace responsable por su contenido. Su contenido no constituye ningun
compromiso para el grupo Atos Origin, salvo ratificacion escrita por ambas partes.
Aunque se esfuerza al maximo por mantener su red libre de virus, el emisor
no puede garantizar nada al respecto y no sera responsable de cualesquiera
danos que puedan resultar de una transmision de virus.
------------------------------------------------------------------
_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users
Andreas Hocevar-2

Re: WFS OpenLayers.ProxyHost Tomcat 5.5

Reply Threaded More More options
Print post
Permalink
In reply to this post by stash
Hi,

you could use the Proxy extension for GeoServer 2.0. For instructions
and download link, go to
http://geoserver.org/display/GEOS/GeoServer+Proxy+Extension.

Regards,
Andreas.

stash wrote:

> Hello,
> I want so show my map with a OpenLayers.Layer.WFS. Therefore I did the same
> as in the openlayers examples to show data with a WFS. But in my case, it
> doesn't work.
>
> After some reading in the internet i found out, that I have to configure a
> OpenLayers.ProxyHost to show the data with a WFS.
>
> In the examples I always found this type of code:
> OpenLayers.ProxyHost="/proxy/?url=";
>
> What does that mean? Furthermore I found out, that I have to configure more,
> when I use Tomcat.
>
> In my case I use a Server with Tomcat 5.5 installed and Geoserver to connect
> to WFS
>
> http://IP:PORT/geoserver/wfs
>
> What do I have to configure that I can show my data on Map over WFS.
>
> (Sorry for my english, it is not the best)
>
> Regards
> stash
>
>  


--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.

_______________________________________________
Users mailing list
[hidden email]
http://openlayers.org/mailman/listinfo/users