Dear Saul
Many thanks for your reply on WMS requests, using POST & GET. I am much
clearer on the theory now. However when trying to put theory into
practice, I am not succeeding.
I was wondering if I might explain to you what I am trying to do so so
that you, or any other reader, might be able to help. I am studying with
UNIGIS and for my thesis I am looking at the suitability of open source
web mapping products (GeoServer, MapServer, Deegree and MapGuide Open
Source) for use by Local Government within the UK. I am currently
reading the OGC specifications in order to understand product
functionality well. However when I try to put the OGC SLD specification
into practice I fail. I detail below what I have tried to do (it looks
much longer than it is) and I would be very grateful if you could offer
any help with anything.
Many Thanks
John Roberts
Manchester, UK
1. Basic WMS GetMap Request – Successful!
I have taken a basic WMS GetMap request based on a demo deegree WMS
service.
http://demo.deegree.org:8080/deegree/wms?
SERVICE=WMS
&version=1.1.1
&request=GetMap
&layers=europe:country
&styles=default:europe:country
&srs=EPSG:4326
&bbox=-15,50,5,60
&width=600
&height=600
&format=image/png
2. Using SLD with KVP’s and the SLD parameter – Failure!
I have tried then to follow the OGC SLD specification (page 8) which
states that the layers and styles parameters can be enclosed in an
example.xml file and referred to using a sld KVP.
The sample.xml file is as follows:
<StyledLayerDescriptor version="1.0.0">
<NamedLayer>
<Name>europe:country</Name>
<NamedStyle>
<Name>default:europe:country</Name>
</NamedStyle>
</NamedLayer>
</StyledLayerDescriptor>
The request is altered as so (I have apache set up on Fedora Core 4):
http://demo.deegree.org:8080/deegree/wms?
SERVICE=WMS
&version=1.1.1
&request=GetMap
&sld=”http://localhost/sample.xml”
&srs=EPSG:4326
&bbox=-15,50,5,60
&width=600
&height=600
&format=image/png
I get a WMS error about a malformed URL. However I suspect this is to do
with permissions but I am not sure.
What I am looking for is information on:
a) is the format of the xml file I have used correct and what is the
best reference for the rules for creating SLD xml files?
b) what are the rules for where SLD xml files can be held?
3. Using SLD with KVP’s and the SLD_BODY paramter – Failure!
I have tried then to follow the OGC SLD specification (page 9) which
states that the layers and styles parameters can be enclosed as a KVP
pair
The request is altered as so:
http://demo.deegree.org:8080/deegree/wms?
SERVICE=WMS
&version=1.1.1
&request=GetMap
&sld_body=<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE
StyledLayerDescriptor SYSTEM
"http://www.opengis.net/sld/"><StyledLayerDescriptor
version="1.0.0"><NamedLayer><Name>europe:country</Name><NamedStyle><Name>default:europe:country</Name></NamedStyle></NamedLayer></StyledLayerDescriptor>
&srs=EPSG:4326
&bbox=-15,50,5,60
&width=600
&height=600
&format=image/png
I get an error that reports an exception during the parsing of the sld
statement.
What information I am looking for is:
a) what are the extra objects (xml and !doctype) and the !doctype
attribute system that are added into the KVP which are not part of the
sld xml document and where can I find information on them?
b) what are the specifications for the formatting of the sld_body KVP to
get it to work?
4 Using SLD with HTTP, POST & XML
I attach a xml document which I believe would be appropriate for the
above request to send via HTTP POST (purloined from the SLD
specification and altered to this example)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE GetMap
SYSTEM "http://some.site.com/wms/GetMap.xsd">
<ogc:GetMap xmlns:ogc="http://www.opengis.net/ows"
xmlns:gml="http://www.opengis.net/gml"
env:encodingStyle="http://www.w3.org/2001/09/soap-
encoding"
version="1.1.1" service="WMS">
<StyledLayerDescriptor version="1.0.0">
<NamedLayer>
<Name>europe:country</Name>
<NamedStyle>
<Name>default:europe:country</Name>
</NamedStyle>
</NamedLayer>
</StyledLayerDescriptor>
<BoundingBox
srsName="http://www.opengis.net/gml/srs/epsg.xml#4326">
<gml:coord>
<gml:X>-15</gml:X>
<gml:Y>50</gml:Y>
</gml:coord>
<gml:coord>
<gml:X>5</gml:X>
<gml:Y>60</gml:Y>
</gml:coord>
</BoundingBox>
<Output>
<Format>image/png</Format>
<Transparent>false</Transparent>
<Size>
<Width>600</Width>
<Height>600</Height>
</Size>
</Output>
<Exceptions>application/vnd.ogc.se+xml</Exceptions>
</ogc:GetMap>
What I don't understand is:
a)what are the xml, !DOCTYPE, ogc, exceptions objects and where can I
find information on them. I am interested in knowing how to correctly
write the documents.
b)how does javascript send this? I have worked out a function which I
believe would do this (I attach it below) but I have no idea how to get
the xml document above into the send method below.
c) Do real programming languages have an object similar to javascript
and how to they send the xml document?
function degpost()
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.open ("POST", "http://demo.deegree.org:8080/deegree/wms?",
true);
xmlhttp.send("");
}
<input type="button" onclick="degpost()" value="Post to Deegree">
***********************************************************************
From:
Saul Farber
<Saul.Farber@anonymised.com>
To:
John Roberts
<johnemyr@anonymised.com>
Cc:
geoserver-users@lists.sourceforge.net
Subject:
Re: [Geoserver-users] POST XML
document/WMS
Date:
Fri, 28 Jul 2006 13:53:48 -0400
(18:53 BST)
> I have spotted the following line at:
> http://docs.codehaus.org/display/GEOSDOC/WMS
>
> c) (http post) WMS GetMap 1.2 Send the SLD (and other request
> parameters) in a POST XML document. This is how the SLD spec
says you
> should do it.
>
> I have also experimented with a HTML form (I attach as a text
document)
>
> I have realised that I can get the GetMap request to work on
the NASA
> wms server 'http://wms.jpl.nasa.gov/wms.cgi?’ using a HTML
form, the URL
> being the action and all the parameters being held in hidden
inputs.
> This works with both 'GET' and 'POST' actions - which I am not
sure what
> this means exactly!.
Yeah, people can be unclear on this particular topic, and tend
to
shorthand inaccurately.
Here's the deal with WMS requests via GET vs. WMS requests via
POST.
There are two styles in which you can request a map from a WMS.
One is
to encode your request parameters in a Key-Value-Pair style
(KVP). So,
for example, "bbox=12,12,24,24",
"layers=myns:MyLayer1,myns:MyLayer2)".
If you were to encode a WMS request in a KVP style, you would
take all
the various KVPs (each of which is defined in the WMS spec),
stick
ampersands between them and submit the whole long KVP string to
the
server via *either* HTTP-GET or HTTP-POST. HTTP-GET will put
the KVPs
in the URL string, while HTTP-POST puts them in the body of the
HTTP
request. Either way, what's important about this is that
you're
encoding your WMS request as a KEY-VALUE-PAIR WMS request.
HTML pages using the <form> element (and without using any
fancy
javascript) *always* encoding things in KVP style. In fact,
it's
probably the case that the WMS modeled its KVP style of encoding
on HTML
<form> semantics, because all browsers act this way and WMS
wanted to be
easily callable from an HTML form.
Separate from the KVP encodings, a quasi-official 'extension' of
the WMS
specification (discussion paper:
http://portal.opengeospatial.org/files/?artifact_id=1118)
defines a
DIFFERENT way to encode WMS requests. Rather than KVPs, this
paper
defines a raw XML-document format, which should be sent as the
SOLE
content of the body of an HTTP-POST request. Unlike the above
KVP via
HTTP-POST request (where the POST body was a bunch of Key-Value
pairs),
the body of an HTTP-POST with XML request is ONLY THE XML. No
equals
signs, no "xml=" parameter and nothing extra in the url.
This definition is not particularly compatible with standard
non-javascript HTML forms, and I don't think you can have a
browser POST
(via a <form action="mywms"> tag) an all-XML WMS request without
the use
of javascript. I'll continue below.
>
> What I don't understand is how I would put this request into a
XML
> document and use the HTTP POST methodology to send it to the
server and
> hence, in theory, be able to incorporate a SLD. I have been
looking on
> the internet and have come across many
technologies/specifications and
> more (e.g. xml, xml http request object, soap).
> Can you send a XML document via HTTP post using an internet
browser or
> does it require specialised software?
>
It turns out that the WMS and WFS specifications aren't the
only
technologies in the entire world that want to use the body of
an
HTTP-POST request as the transport for XML messages or
documents
(without any KVPs at all, remember!) For example, SOAP does
this, as do
many of the google apis, yahoo apis and innumerable other
web-based apis.
So what is a web developer to do? We'd love to be able to send
raw XML
requests as the body of an HTTP-POST request, but there's no way
to do
it from HTML! Well, the folks at microsoft, mozilla, apple and
opera
all came up with remarkably similar ways of doing this using a
special
javascript object. Generically, the technology is called
'XMLHttpObject', and while the specific implementations and
javascript
calls that you have to make differ from browser to browser
(making web
developers around the world sigh in pain), there is a way to
use
javascript inside a web-browser to craft just these sorts of
HTTP-POST
requests with XML inside them.
In addition, many 'heavierweight' technologies have supported
direct XML
POST for a long time. Java clients, .Net clients, python, php,
perl...pretty much any real programming language can do it
easily. It
just took the javascript vendors (MS, Mozilla, Apple, Opera,
etc.) a
long time to get an almost-consistent implementation into their
browsers.
All of this, by the way, applies just as accurately to WFS as
well.
Except WFS has had the XML-POST stuff built in to the spec from
the very
beginning, whereas the WMS had it 'tacked on' later.
Hopefully that helps a bit. I'd suggest looking at
XMLHttpObject if
you're married to the idea of using javascript in a web-browser
to
access a WMS via HTTP-XML POST. That said, what you get back
from a WMS
is generally a raw image stream, so I'm not sure you'd have a
lot of
luck getting the image into the web page (anyone know if you can
do this?).
One thing that strikes me about your email is the following
sentence:
> to send it to the server and
> hence, in theory, be able to incorporate a SLD.
If your concern is that you want to incorporate an SLD into your
WMS
request, you can do so while still using the KVP encoding style
(which
can be much more browser friendly). Simply craft your SLD, and
add it
as yet another Key-Value-Parameter:
http://server/geoserver/wms?request=getmap&...&SLD=<my><sld><goes><here></here></goes></sld></my>
This way you get the full expressiveness of SLD, and you can
load your
image simply by using that URL as the value of an <img
src="http://url…"> parameter.
Good luck!
--saul
> I was hoping that somebody would be able to direct me as to
what I would
> need to study in a logical order to understand this subject or
even to
> offer some explanation. I am not quite sure how big a subject
I am
> trying to broach.
>
> I wish to understand this as I am surmising that what the WMS
server
> offers in terms of how the data is requested will affect the
WMS client
> software it can be linked to (for example
MapBuilder,MapBender).
>
> I found an OpenGIS discussion paper covering this but I
couldn't make
> much sense of it. I attach the paper.
>
> Whilst I am here, I have some another query for anybody who
has got this
> far!
> 'All Registered Products' on the OGC website:
> http://www.opengeospatial.org/resource/products
> Does anybody know what criteria need to be met to be compliant
(green)
> or implementing (blue)?
>
>
> Any help that anybody could give would be very gratefully
received.
>
> Many Thanks
>
> John
___________________________________________________________
Now you can scan emails quickly with a reading pane. Get the new Yahoo! Mail. http://uk.docs.yahoo.com/nowyoucan.html