[Geoserver-users] POST XML document/WMS

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/&quot;&gt;&lt;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&quot;&gt;
<ogc:GetMap xmlns:ogc="http://www.opengis.net/ows&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
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&quot;&gt;
<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?&quot;,
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=&lt;my&gt;&lt;sld&gt;&lt;goes&gt;&lt;here&gt;&lt;/here&gt;&lt;/goes&gt;&lt;/sld&gt;&lt;/my&gt;
        
        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

Whew, john. You've got some big questions here! I'll make a deal with you. If I explain these bits to you, will you document what you've learned as thoroughly as you can, and post it to the geoserver wiki under "A complete guide to using and understanding OGC web services"?

I think the path you're following is one that many people are too overwhelmed to follow, and if you can successfully navigate it, and then document how those after you could do so as well, it would be a huge help to the geoserver project.

Also, let me prefix this entire email by pointing out that you're connecting to a *specific implementation of a specification.* Unfortunately, the specification published by the OGC is not completely unambiguous. It also only specifies behavior...it doesn't specific the internal implementation which determines the behavior. You seem to be using a demo server provided by the deegree project. They are ONE of many implementors of the WMS specification. Geoserver is another (also open source, like deegree). Mapserver (AKA UMN Mapserver or Minnesota Mapserver) is another open-source one. IONIC Red-Spider is a commercial/proprietary implementation. So is cubewerx's product (not sure of the name). ESRI provides a limited WMS connector, and I'm sure many others do too.

Sometimes, issues develop which are specific to the implementation you're using. XML is a rather pedantic standard, and many implementations are "forgiving" in some specific ways (namespaces, capitalization, etc). However, a request that is "forgiven" by deegree, might not be "forgiven" by geoserver. So (as usual) the devil is in the details and while conformance to the WMS specification is a useful yardstick...it's not an absolute guarantee that everything will always work seamlessly with any implementation.

Again, you're USING degree, but you're asking general WMS questions of the geoserver folks. You might consider using geoserver, cause our knowledge can be specific to geoserver sometimes.

Ok, see my ideas inline.

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>

This looks fine (I think!)

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

The server 'demo.deegree.org" is at 131.220.126.148, which is likely a server in germany. When you send it this command (I'm calling your URL a command, because it sort-of is one), your command says:

"render the sld located at 'http://localhost/sample.xml’".

Unfortunately, 'localhost' refers to the LOCAL computer (wherever that computer actually is). So the degree server in germany is going to ITSELF to look for your sample.xml file. But there's no sample.xml file on demo.deegree.org. Unless you have access to that server, I guess. You need to use an address which the demo.deegree.org server can use to access your file. If you are on a publically routed IP address, then use your ip address. Otherwise, you'll have to put your xml file somewhere that can be publically accessed.

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/&quot;&gt;&lt;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.

Yeah, I'd dump the <?xml version="1.0".. part and the <!DOCTYPE part, too. Just start right with the <StyledLayerDescriptor version="1.0.0"> part.

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?

The first paragraph here explains this well.
http://www.xml.com/pub/a/2002/09/04/xslt.html

This page explains what that doctype is trying to do:
http://www.w3schools.com/xml/xml_dtd.asp

b) what are the specifications for the formatting of the sld_body KVP to
get it to work?

Differs from implementation to implementation. Generally, it should be valid XML, and what you have above *should* probably work. I'd submit it as a bug to the deegree folks.

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&quot;&gt;
<ogc:GetMap xmlns:ogc="http://www.opengis.net/ows&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
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&quot;&gt;
<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.

The "Exceptions" tag tells the server how you want your exceptions returned. From the spec:

application/vnd.ogc.se+xml = an xml message
application/vnd.ogc.se+inimage = an image with the error message printed on it
application/vnd.ogc.se+blank = a blank image

As for general XML knowledge, try here:
http://www.w3schools.com/xml/default.asp

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.

Your function looks ok...but javascript programming is something that takes time, energy and a bit of luck to get right. Try using firefox and using the Venkmann script debugger, or else simply the "Javascript Console". Often these tools (which are specific to firefox) will give you decent debugging info about what's going on in your javascript page.

c) Do real programming languages have an object similar to javascript
and how to they send the xml document?

Yes. Most real programming languages have something similar to this javascript object. Most also allow you to access things at a much lower level as well, to get even finer grained control of your network connections.

function degpost()
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.open ("POST", "http://demo.deegree.org:8080/deegree/wms?&quot;,
true);
xmlhttp.send("");
}
<input type="button" onclick="degpost()" value="Post to Deegree">

This looks good, except be sure that the xmlhttp.send("") call actually sends the XML that you've written above!

I guess my conclusion is, you're on the right track. Now start debugging!

good luck.

--saul

Dear Saul

Many thanks for getting back to me,

Again, you have given me alot to go at. I think it is most definitely
the time for me to go away and install GeoServer on my machine and try
to implement the different methods of using SLD successfully.

I will definitely post the notes/sections from my thesis which relate to
the OGC web services as well as others that might be of interest to
people. I am developing a matrix which will compare and contrast the
functionality of GeoServer, MapServer, Deegree and MapGuide Open Source.
I am currently basing this firmly around OGC specifications which
explains my current mania for them! I will be putting this onto the
mailing list for comments in the near future.

I will of course check for accuracy with Chris Holmes and other users
via this mailing list before putting anything up and in the process
hopefully gain more useful input from people!

Any comments in the meantime by any interested parties would be most
welcome!

Kind Regards

John Roberts
Manchester, UK

On Tue, 2006-08-01 at 13:39 -0400, Saul Farber wrote:

Whew, john. You've got some big questions here! I'll make a deal with
you. If I explain these bits to you, will you document what you've
learned as thoroughly as you can, and post it to the geoserver wiki
under "A complete guide to using and understanding OGC web services"?

I think the path you're following is one that many people are too
overwhelmed to follow, and if you can successfully navigate it, and then
document how those after you could do so as well, it would be a huge
help to the geoserver project.

Also, let me prefix this entire email by pointing out that you're
connecting to a *specific implementation of a specification.*
Unfortunately, the specification published by the OGC is not completely
unambiguous. It also only specifies behavior...it doesn't specific the
internal implementation which determines the behavior. You seem to be
using a demo server provided by the deegree project. They are ONE of
many implementors of the WMS specification. Geoserver is another (also
open source, like deegree). Mapserver (AKA UMN Mapserver or Minnesota
Mapserver) is another open-source one. IONIC Red-Spider is a
commercial/proprietary implementation. So is cubewerx's product (not
sure of the name). ESRI provides a limited WMS connector, and I'm sure
many others do too.

Sometimes, issues develop which are specific to the implementation
you're using. XML is a rather pedantic standard, and many
implementations are "forgiving" in some specific ways (namespaces,
capitalization, etc). However, a request that is "forgiven" by deegree,
might not be "forgiven" by geoserver. So (as usual) the devil is in the
details and while conformance to the WMS specification is a useful
yardstick...it's not an absolute guarantee that everything will always
work seamlessly with any implementation.

Again, you're USING degree, but you're asking general WMS questions of
the geoserver folks. You might consider using geoserver, cause our
knowledge can be specific to geoserver sometimes.

Ok, see my ideas inline.

>
> 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>

This looks fine (I think!)

>
>
> 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

The server 'demo.deegree.org" is at 131.220.126.148, which is likely a
server in germany. When you send it this command (I'm calling your URL
a command, because it sort-of is one), your command says:

"render the sld located at 'http://localhost/sample.xml’".

Unfortunately, 'localhost' refers to the LOCAL computer (wherever that
computer actually is). So the degree server in germany is going to
ITSELF to look for your sample.xml file. But there's no sample.xml file
on demo.deegree.org. Unless you have access to that server, I guess.
You need to use an address which the demo.deegree.org server can use to
access your file. If you are on a publically routed IP address, then
use your ip address. Otherwise, you'll have to put your xml file
somewhere that can be publically accessed.

>
>
> 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/&quot;&gt;&lt;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.

Yeah, I'd dump the <?xml version="1.0".. part and the <!DOCTYPE part,
too. Just start right with the <StyledLayerDescriptor version="1.0.0">
part.

> 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?

The first paragraph here explains this well.
http://www.xml.com/pub/a/2002/09/04/xslt.html

This page explains what that doctype is trying to do:
http://www.w3schools.com/xml/xml_dtd.asp

> b) what are the specifications for the formatting of the sld_body KVP to
> get it to work?
>
Differs from implementation to implementation. Generally, it should be
valid XML, and what you have above *should* probably work. I'd submit
it as a bug to the deegree folks.

>
> 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&quot;&gt;
> <ogc:GetMap xmlns:ogc="http://www.opengis.net/ows&quot;
> xmlns:gml="http://www.opengis.net/gml&quot;
> 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&quot;&gt;
> <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.

The "Exceptions" tag tells the server how you want your exceptions
returned. From the spec:

application/vnd.ogc.se+xml = an xml message
application/vnd.ogc.se+inimage = an image with the error message printed
on it
application/vnd.ogc.se+blank = a blank image

As for general XML knowledge, try here:
http://www.w3schools.com/xml/default.asp

> 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.

Your function looks ok...but javascript programming is something that
takes time, energy and a bit of luck to get right. Try using firefox
and using the Venkmann script debugger, or else simply the "Javascript
Console". Often these tools (which are specific to firefox) will give
you decent debugging info about what's going on in your javascript page.

> c) Do real programming languages have an object similar to javascript
> and how to they send the xml document?

Yes. Most real programming languages have something similar to this
javascript object. Most also allow you to access things at a much lower
level as well, to get even finer grained control of your network
connections.

>
>
> function degpost()
> {
> var xmlhttp = new XMLHttpRequest();
> xmlhttp.open ("POST", "http://demo.deegree.org:8080/deegree/wms?&quot;,
> true);
> xmlhttp.send("");
> }
> <input type="button" onclick="degpost()" value="Post to Deegree">
>

This looks good, except be sure that the xmlhttp.send("") call actually
sends the XML that you've written above!

I guess my conclusion is, you're on the right track. Now start debugging!

good luck.

--saul

___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html

Just my 2 cents comment on Javascript debugging after the very complete answer from Saul. So far the best for xmlhttprequest (aka ajax) debugging is firebug (https://addons.mozilla.org/firefox/1843/), a firefox extension which can be very helpful for ajax call debugging, it shows you all details you want.
I hope it can help you.

Gerald

On Aug 2, 2006, at 2:48 AM, John Roberts wrote:

Dear Saul

Many thanks for getting back to me,

Again, you have given me alot to go at. I think it is most definitely
the time for me to go away and install GeoServer on my machine and try
to implement the different methods of using SLD successfully.

I will definitely post the notes/sections from my thesis which relate to
the OGC web services as well as others that might be of interest to
people. I am developing a matrix which will compare and contrast the
functionality of GeoServer, MapServer, Deegree and MapGuide Open Source.
I am currently basing this firmly around OGC specifications which
explains my current mania for them! I will be putting this onto the
mailing list for comments in the near future.

I will of course check for accuracy with Chris Holmes and other users
via this mailing list before putting anything up and in the process
hopefully gain more useful input from people!

Any comments in the meantime by any interested parties would be most
welcome!

Kind Regards

John Roberts
Manchester, UK

On Tue, 2006-08-01 at 13:39 -0400, Saul Farber wrote:

Whew, john. You've got some big questions here! I'll make a deal with
you. If I explain these bits to you, will you document what you've
learned as thoroughly as you can, and post it to the geoserver wiki
under "A complete guide to using and understanding OGC web services"?

I think the path you're following is one that many people are too
overwhelmed to follow, and if you can successfully navigate it, and then
document how those after you could do so as well, it would be a huge
help to the geoserver project.

Also, let me prefix this entire email by pointing out that you're
connecting to a *specific implementation of a specification.*
Unfortunately, the specification published by the OGC is not completely
unambiguous. It also only specifies behavior...it doesn't specific the
internal implementation which determines the behavior. You seem to be
using a demo server provided by the deegree project. They are ONE of
many implementors of the WMS specification. Geoserver is another (also
open source, like deegree). Mapserver (AKA UMN Mapserver or Minnesota
Mapserver) is another open-source one. IONIC Red-Spider is a
commercial/proprietary implementation. So is cubewerx's product (not
sure of the name). ESRI provides a limited WMS connector, and I'm sure
many others do too.

Sometimes, issues develop which are specific to the implementation
you're using. XML is a rather pedantic standard, and many
implementations are "forgiving" in some specific ways (namespaces,
capitalization, etc). However, a request that is "forgiven" by deegree,
might not be "forgiven" by geoserver. So (as usual) the devil is in the
details and while conformance to the WMS specification is a useful
yardstick...it's not an absolute guarantee that everything will always
work seamlessly with any implementation.

Again, you're USING degree, but you're asking general WMS questions of
the geoserver folks. You might consider using geoserver, cause our
knowledge can be specific to geoserver sometimes.

Ok, see my ideas inline.

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>

This looks fine (I think!)

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

The server 'demo.deegree.org" is at 131.220.126.148, which is likely a
server in germany. When you send it this command (I'm calling your URL
a command, because it sort-of is one), your command says:

"render the sld located at 'http://localhost/sample.xml’".

Unfortunately, 'localhost' refers to the LOCAL computer (wherever that
computer actually is). So the degree server in germany is going to
ITSELF to look for your sample.xml file. But there's no sample.xml file
on demo.deegree.org. Unless you have access to that server, I guess.
You need to use an address which the demo.deegree.org server can use to
access your file. If you are on a publically routed IP address, then
use your ip address. Otherwise, you'll have to put your xml file
somewhere that can be publically accessed.

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/&quot;&gt;&lt;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.

Yeah, I'd dump the <?xml version="1.0".. part and the <!DOCTYPE part,
too. Just start right with the <StyledLayerDescriptor version="1.0.0">
part.

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?

The first paragraph here explains this well.
http://www.xml.com/pub/a/2002/09/04/xslt.html

This page explains what that doctype is trying to do:
http://www.w3schools.com/xml/xml_dtd.asp

b) what are the specifications for the formatting of the sld_body KVP to
get it to work?

Differs from implementation to implementation. Generally, it should be
valid XML, and what you have above *should* probably work. I'd submit
it as a bug to the deegree folks.

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&quot;&gt;
<ogc:GetMap xmlns:ogc="http://www.opengis.net/ows&quot;
xmlns:gml="http://www.opengis.net/gml&quot;
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&quot;&gt;
<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.

The "Exceptions" tag tells the server how you want your exceptions
returned. From the spec:

application/vnd.ogc.se+xml = an xml message
application/vnd.ogc.se+inimage = an image with the error message printed
on it
application/vnd.ogc.se+blank = a blank image

As for general XML knowledge, try here:
http://www.w3schools.com/xml/default.asp

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.

Your function looks ok...but javascript programming is something that
takes time, energy and a bit of luck to get right. Try using firefox
and using the Venkmann script debugger, or else simply the "Javascript
Console". Often these tools (which are specific to firefox) will give
you decent debugging info about what's going on in your javascript page.

c) Do real programming languages have an object similar to javascript
and how to they send the xml document?

Yes. Most real programming languages have something similar to this
javascript object. Most also allow you to access things at a much lower
level as well, to get even finer grained control of your network
connections.

function degpost()
{
var xmlhttp = new XMLHttpRequest();
xmlhttp.open ("POST", "http://demo.deegree.org:8080/deegree/wms?&quot;,
true);
xmlhttp.send("");
}
<input type="button" onclick="degpost()" value="Post to Deegree">

This looks good, except be sure that the xmlhttp.send("") call actually
sends the XML that you've written above!

I guess my conclusion is, you're on the right track. Now start debugging!

good luck.

--saul

___________________________________________________________
The all-new Yahoo! Mail goes wherever you go - free your email address from your Internet provider. http://uk.docs.yahoo.com/nowyoucan.html

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Dear Saul

I have been away experimenting and I have installed GeoServer on Linux.
I have been playing with the XMLHttpRequest object and have advanced but
met some problems and peculiar effects. If you, or any other interested
individual, has any suggestions/comments I would be very interested to
hear. I am just playing with this to try and understand the POST request
better so therefore please don't anybody devote much time to it unless
it interests them also!

I have created a HTML file (see below) which creates a XMLHttpRequest
object which I have placed in /usr/local/geoserver/server/geoserver/ and
hence accessed through http://localhost:8080/geoserver/xmlhttp.html

The idea is that the XMLHttpRequest object returns the GetCapabilities
document for my GeoServer by way of a POST request. Unfortunately I can
only get an exception report. I can see the exception report by using
an alert for the responseText property of the XMLHttpRequest object.

1. Do you have any suggestions for the xml document I am trying to send.
I have started looking at the w3schools site as you suggested.

2. I get the weirdest effect as I have two alerts using the responseText
property. One returns null and the other returns the exception report.
If I comment out either, the other returns null!

3. Do you have any suggestions for a better method of viewing the
responseText.

4. If you use the GetMap request, does the image get returned in the
responseText property still?

***********************************************************

<HTML>
<HEAD>
<TITLE>
Post HTTP
</TITLE>
<script type="text/javascript">

function firsttry () {
var xmlhttp;
var url;
<!-- code for Mozilla -->
if (window.XMLHttpRequest)
{ xmlhttp=new XMLHttpRequest(); }

<!-- code for Internet Explorer -->
else if (window.ActiveXObject)
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }

url = "http://localhost:8080/geoserver/wms?&quot;;
xmlhttp.open ("POST", url, true);
xmlhttp.send("<?xml version='1.0'?>" +
' <!DOCTYPE GetCapabilities > ' +
' <ogc:GetCapabilities service="WMS" version="1.1.1" ' +
' </ogc:GetCapabilities>');

xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState==4) {
alert(xmlhttp.responseText);}}

alert(xmlhttp.responseText);
}
</script>
</HEAD><BODY><FORM>
<INPUT TYPE="submit" value="push here" onclick="firsttry();">
</FORM></BODY></HTML>

**********************************************************************************

On Tue, 2006-08-01 at 13:39 -0400, Saul Farber wrote:

Whew, john. You've got some big questions here! I'll make a deal with
you. If I explain these bits to you, will you document what you've
learned as thoroughly as you can, and post it to the geoserver wiki
under "A complete guide to using and understanding OGC web services"?

I think the path you're following is one that many people are too
overwhelmed to follow, and if you can successfully navigate it, and then
document how those after you could do so as well, it would be a huge
help to the geoserver project.

Also, let me prefix this entire email by pointing out that you're
connecting to a *specific implementation of a specification.*
Unfortunately, the specification published by the OGC is not completely
unambiguous. It also only specifies behavior...it doesn't specific the
internal implementation which determines the behavior. You seem to be
using a demo server provided by the deegree project. They are ONE of
many implementors of the WMS specification. Geoserver is another (also
open source, like deegree). Mapserver (AKA UMN Mapserver or Minnesota
Mapserver) is another open-source one. IONIC Red-Spider is a
commercial/proprietary implementation. So is cubewerx's product (not
sure of the name). ESRI provides a limited WMS connector, and I'm sure
many others do too.

Sometimes, issues develop which are specific to the implementation
you're using. XML is a rather pedantic standard, and many
implementations are "forgiving" in some specific ways (namespaces,
capitalization, etc). However, a request that is "forgiven" by deegree,
might not be "forgiven" by geoserver. So (as usual) the devil is in the
details and while conformance to the WMS specification is a useful
yardstick...it's not an absolute guarantee that everything will always
work seamlessly with any implementation.

Again, you're USING degree, but you're asking general WMS questions of
the geoserver folks. You might consider using geoserver, cause our
knowledge can be specific to geoserver sometimes.

Ok, see my ideas inline.

>
> 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>

This looks fine (I think!)

>
>
> 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

The server 'demo.deegree.org" is at 131.220.126.148, which is likely a
server in germany. When you send it this command (I'm calling your URL
a command, because it sort-of is one), your command says:

"render the sld located at 'http://localhost/sample.xml’".

Unfortunately, 'localhost' refers to the LOCAL computer (wherever that
computer actually is). So the degree server in germany is going to
ITSELF to look for your sample.xml file. But there's no sample.xml file
on demo.deegree.org. Unless you have access to that server, I guess.
You need to use an address which the demo.deegree.org server can use to
access your file. If you are on a publically routed IP address, then
use your ip address. Otherwise, you'll have to put your xml file
somewhere that can be publically accessed.

>
>
> 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/&quot;&gt;&lt;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.

Yeah, I'd dump the <?xml version="1.0".. part and the <!DOCTYPE part,
too. Just start right with the <StyledLayerDescriptor version="1.0.0">
part.

> 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?

The first paragraph here explains this well.
http://www.xml.com/pub/a/2002/09/04/xslt.html

This page explains what that doctype is trying to do:
http://www.w3schools.com/xml/xml_dtd.asp

> b) what are the specifications for the formatting of the sld_body KVP to
> get it to work?
>
Differs from implementation to implementation. Generally, it should be
valid XML, and what you have above *should* probably work. I'd submit
it as a bug to the deegree folks.

>
> 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&quot;&gt;
> <ogc:GetMap xmlns:ogc="http://www.opengis.net/ows&quot;
> xmlns:gml="http://www.opengis.net/gml&quot;
> 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&quot;&gt;
> <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.

The "Exceptions" tag tells the server how you want your exceptions
returned. From the spec:

application/vnd.ogc.se+xml = an xml message
application/vnd.ogc.se+inimage = an image with the error message printed
on it
application/vnd.ogc.se+blank = a blank image

As for general XML knowledge, try here:
http://www.w3schools.com/xml/default.asp

> 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.

Your function looks ok...but javascript programming is something that
takes time, energy and a bit of luck to get right. Try using firefox
and using the Venkmann script debugger, or else simply the "Javascript
Console". Often these tools (which are specific to firefox) will give
you decent debugging info about what's going on in your javascript page.

> c) Do real programming languages have an object similar to javascript
> and how to they send the xml document?

Yes. Most real programming languages have something similar to this
javascript object. Most also allow you to access things at a much lower
level as well, to get even finer grained control of your network
connections.

>
>
> function degpost()
> {
> var xmlhttp = new XMLHttpRequest();
> xmlhttp.open ("POST", "http://demo.deegree.org:8080/deegree/wms?&quot;,
> true);
> xmlhttp.send("");
> }
> <input type="button" onclick="degpost()" value="Post to Deegree">
>

This looks good, except be sure that the xmlhttp.send("") call actually
sends the XML that you've written above!

I guess my conclusion is, you're on the right track. Now start debugging!

good luck.

--saul

exception.png

John,

Welcome to the weird world of javascript programming!

One thing that jumps out at me is that your XML isn't well-formed for the GetCapabilities request.

Here's what you're sending:

xmlhttp.send("<?xml version='1.0'?>" +
' <!DOCTYPE GetCapabilities > ' +
' <ogc:GetCapabilities service="WMS" version="1.1.1" ' +
' </ogc:GetCapabilities>');

That is, you're sending:
<?xml version='1.0'?><!DOCTYPE GetCapabilities ><ogc:GetCapabilities service="WMS" version="1.1.1"</ogc:GetCapabilities>

That's not well-formed XML. Try putting a ">" after the '1.1.1', so you get the standard:

'<tag></tag>'
format.

I think the reason that your first popup is printing null is that you're posting asynchronously [ xmlhttp.open("POST",url, *true*) ], and this causes the xmlhttp.send() method to return immediately. The assignment xmlhttp.onreadystatechange = function () {...} is just an assignment, so that's pretty quick too. Then the first alert prints. Since xmlhttp hasn't actually had a chance to *do* anything yet (it's just been told to send() nanoseconds earlier), the lower 'alert()' call return null. xmlhttp.responseText just hasn't been calculated yet!

Later on, you get an error because your XML message to the server was malformed (when the onreadystatechanged function is called).

The strangeness about interconnected commenting I can't explain, however.

--saul

John Roberts wrote:

Dear Saul

I have been away experimenting and I have installed GeoServer on Linux.
I have been playing with the XMLHttpRequest object and have advanced but
met some problems and peculiar effects. If you, or any other interested
individual, has any suggestions/comments I would be very interested to
hear. I am just playing with this to try and understand the POST request
better so therefore please don't anybody devote much time to it unless
it interests them also!

I have created a HTML file (see below) which creates a XMLHttpRequest
object which I have placed in /usr/local/geoserver/server/geoserver/ and
hence accessed through http://localhost:8080/geoserver/xmlhttp.html

The idea is that the XMLHttpRequest object returns the GetCapabilities
document for my GeoServer by way of a POST request. Unfortunately I can
only get an exception report. I can see the exception report by using
an alert for the responseText property of the XMLHttpRequest object.

1. Do you have any suggestions for the xml document I am trying to send.
I have started looking at the w3schools site as you suggested.

2. I get the weirdest effect as I have two alerts using the responseText
property. One returns null and the other returns the exception report.
If I comment out either, the other returns null!

3. Do you have any suggestions for a better method of viewing the
responseText.

4. If you use the GetMap request, does the image get returned in the
responseText property still?

***********************************************************

<HTML>
<HEAD>
<TITLE>
Post HTTP
</TITLE>
<script type="text/javascript">

function firsttry () {
var xmlhttp;
var url;
<!-- code for Mozilla -->
if (window.XMLHttpRequest)
{ xmlhttp=new XMLHttpRequest(); }

<!-- code for Internet Explorer -->
else if (window.ActiveXObject)
{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }

url = "http://localhost:8080/geoserver/wms?&quot;;
xmlhttp.open ("POST", url, true);
xmlhttp.send("<?xml version='1.0'?>" +
' <!DOCTYPE GetCapabilities > ' +
' <ogc:GetCapabilities service="WMS" version="1.1.1" ' +
' </ogc:GetCapabilities>');

xmlhttp.onreadystatechange = function () {
if (xmlhttp.readyState==4) {
alert(xmlhttp.responseText);}}

alert(xmlhttp.responseText);
}
</script>
</HEAD><BODY><FORM>
<INPUT TYPE="submit" value="push here" onclick="firsttry();">
</FORM></BODY></HTML>

Dear Sirs

I have read Saul's interesting explanations and learned a lot. A bit like
John I am trying to send requests via POST. I send the following XML
request, which is very similar to the one sent by John above:

"<GetCapabilities service=\"WFS\" xmlns=\"http://www.opengis.net/wfs\\&quot; />"

to:

http://localhost:9090/geoserver/wms

That returns the expected XML response. I use Geoserver version 1.6.5 and
send from a Java program. I changed the Jetty's port to 9090 because I
already have Tomcat on 8080 but that should not matter.

So far so good but when I try to issue a similar request in WMS it fails.
Sending:

"<GetCapabilities service=\"WMS\" xmlns=\"http://www.opengis.net/wms\\&quot; />"

to

http://localhost:9090/geoserver/wms

returns "Could not find request reader (either kvp or xml)"

Why is that?

Best Regards and thanks in advance, Johannes

--
View this message in context: http://www.nabble.com/POST-XML-document-WMS-tp5543718p19912068.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

jschade ha scritto:

Dear Sirs

I have read Saul's interesting explanations and learned a lot. A bit like
John I am trying to send requests via POST. I send the following XML
request, which is very similar to the one sent by John above:

"<GetCapabilities service=\"WFS\" xmlns=\"http://www.opengis.net/wfs\\&quot; />"

to:

http://localhost:9090/geoserver/wms

That returns the expected XML response. I use Geoserver version 1.6.5 and
send from a Java program. I changed the Jetty's port to 9090 because I
already have Tomcat on 8080 but that should not matter.

So far so good but when I try to issue a similar request in WMS it fails.
Sending:

"<GetCapabilities service=\"WMS\" xmlns=\"http://www.opengis.net/wms\\&quot; />"

to

http://localhost:9090/geoserver/wms

returns "Could not find request reader (either kvp or xml)"

Why is that?

If you hit the caps with a GET request you'll get the following:

     <Request>
       <GetCapabilities>
         <Format>application/vnd.ogc.wms_xml</Format>
         <DCPType>
           <HTTP>
             <Get>
               <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink&quot; xlink:type="simple" xlink:href="http://localhost:8080/geoserver/wms?SERVICE=WMS&amp;&quot;/&gt;
             </Get>
             <Post>
               <OnlineResource xmlns:xlink="http://www.w3.org/1999/xlink&quot; xlink:type="simple" xlink:href="http://localhost:8080/geoserver/wms?SERVICE=WMS&amp;&quot;/&gt;
             </Post>
           </HTTP>
         </DCPType>
       </GetCapabilities>

As you can see, it requires you to post the request to
http://localhost:8080/geoserver/wms?SERVICE=WMS&
instead of using just
http://localhost:8080/geoserver/wms
and if you post to the former, it'll work.

Why is that, I don't really know , but the whole caps document assumes
http://localhost:8080/geoserver/wms?SERVICE=WMS&
as the entry point for all requests. I find this strange, maybe
Gabriel or Justin (cc'ed) know why things have been setup this way.

Hope this helps
Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.

Why is that, I don't really know , but the whole caps document assumes
http://localhost:8080/geoserver/wms?SERVICE=WMS&
as the entry point for all requests. I find this strange, maybe
Gabriel or Justin (cc'ed) know why things have been setup this way.

Hmmm... well the fact that you can make a WMS caps request in XML is really just a side effect of how the dispatching works... and not intended. AFAIK WMS 1.1.1 does not support GetCapabilities request in xml... as there is no notion of a WMS 1.1.1 schema, hence no namespace, etc... etc...

Hope this helps
Cheers
Andrea

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Dear Andrea

Thank you for your quick intervention. I somehow got myself into a corner
with this and you brought me out of this. The XML request works fine now
that I know about the obligatory query string.

However, reading what Justin says, I decided that it is probably better to
use GET for GetCapabilities.

However your efforts will not be lost. I learned a lot in the process and am
sure to use POST on other occasions.

Mille grazie Signora!

Johannes

Why is that, I don't really know , but the whole caps document assumes
http://localhost:8080/geoserver/wms?SERVICE=WMS&
as the entry point for all requests. I find this strange, maybe
Gabriel or Justin (cc'ed) know why things have been setup this way.

Hmmm... well the fact that you can make a WMS caps request in XML is
really just a side effect of how the dispatching works... and not
intended. AFAIK WMS 1.1.1 does not support GetCapabilities request in
xml... as there is no notion of a WMS 1.1.1 schema, hence no namespace,
etc... etc...

Hope this helps
Cheers
Andrea

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great
prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
View this message in context: http://www.nabble.com/POST-XML-document-WMS-tp5543718p19949193.html
Sent from the GeoServer - User mailing list archive at Nabble.com.

jschade ha scritto:

Dear Andrea

Thank you for your quick intervention. I somehow got myself into a corner
with this and you brought me out of this. The XML request works fine now
that I know about the obligatory query string.

However, reading what Justin says, I decided that it is probably better to
use GET for GetCapabilities.

However your efforts will not be lost. I learned a lot in the process and am
sure to use POST on other occasions.

No problem, it's actually my fault, I should have checked the WMS spec

Mille grazie Signora!

He he, thanks. Just a detail: I'm a man :wink:
I'm aware that besides Italy it's considered to be a female
name, thought the meaning of the name is "Man, warrior; manly",
(so much for a female one!):
http://babynamesworld.parentsconnect.com/meaning_of_Andrea.html

Cheers
Andrea

--
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.