GeoServer学习手记(五):Servlet及HTTP派发过程之二

GeoServer学习手记(五):Servlet及HTTP派发过程之二

粟卫民 日期:2009-10-29

保留所有版权。如需转载,请联系作者,并在醒目位置注明出处

接上篇《GeoServer学习手记(四):Servlet及HTTP派发过程之一》()。

Request

A request can be sent to Geoserver as a GET or a POST, both are handled similarly.

The getFeature process keeps the distinction between a GET and POST until it hits the FeatureRequest object: org.vfny.geoserver.wfs.requests.FeatureRequest. Once you hit FeatureRequest, the code isn’t forked and the request works from one spot, execute(). Read on for more details.

GET and POST

Here is an example HTTP GET request

:8080/geoserver/wfs?request=getfeature&service=wfs&version=1.0.0&typename=states&filter=xmlns:ogc=”http://ogc.org” xmlns:gml=”http://www.opengis.net/gml”>the_geom-73.99312376470733,40.76203427979042 -73.9239210030026,40.80129519821393

Try it

If you have Geoserver set up locally on port 8080, you can enter the above URL and Geoserver will process it.

Try it with this link

Here is an example HTTP XML POST request

:8080/geoserver/wfs outputFormat=”GML2″ xmlns:topp=”http://www.openplans.org/topp” xmlns:wfs=”http://www.opengis.net/wfs” xmlns:ogc=”http://www.opengis.net/ogc” xmlns:gml=”http://www.opengis.net/gml” xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xsi:schemaLocation=”http://www.opengis.net/wfs “> the_geom -73.99312376470733,40.76203427979042 -73.9239210030026,40.80129519821393

Exploring the HTTP GET request URL

There are 6 parts to the URL:

The server address – _:8080/geoserver/wfs_The request type – request=getfeatureThe service type – service=wfsThe version – version=1.0.0The type name, also known as the data you are querying – typename=statesThe filter used to select exactly what you want from the type

The server address points to where your Geoserver instance is running. In this example, on the local machine on port 8080.

The request type is the command that you are sending to the server. In this case the URL is asking “get me some features”. There are other commands that can be sent:

GetFeature (the case we are analyzing)TransactionLockFeatureGetFeatureWithLockGetFeatureInfoGetCapabilities

Service type tells the server what service mode you want. Here we want WFS. Another possible service is WMS.

Version number of the WFS specification that is used (1.0.0).

The type name is the FeatureType that you are querying, also known as the data. In our example, a shapefile that contains US states.

The filter is a restriction on our query. It pretty much says “restrict my query to only features in this bounding box”. There are many filters you can use, but we will not explore them in this tutorial. Here is the sleep inducing OGC Filter specification if you really want to learn more.

How Geoserver interperets the request

Here is the overview of the program flow, in a bit of an abstract view.

Entry Point

When the request comes in, the servlet container (ie. jetty or tomcat) will send the request to the WfsDispatcher. This is the entry point for Geoserver to process the results.

You can set up where this entry point is by changing your web.xml file. Located in %GEOSERVER_HOME%/server/geoserver/WEB-INF

Here is the part of the xml file that we want:

WfsDispatcher org.vfny.geoserver.wfs.servlets.WfsDispatcher … WfsDispatcher /wfs/* 最重要的是今天的心。

GeoServer学习手记(五):Servlet及HTTP派发过程之二

相关文章:

你感兴趣的文章:

标签云: