[geotk] code for parsing WMS Capabilities docs

Cédric Briançon cedric.briancon at geomatys.fr
Fri May 21 05:29:36 EDT 2010


Hi everyone,

from what I red on the web, JAXB in version 2 propose a validation 
process that is not done by default. To validate a WMS GetCapabilities 
response, we have to use the method Unmarshaller#setSchema(schema), more 
information at 
http://java.sun.com/javase/6/docs/api/javax/xml/bind/Unmarshaller.html.

I know that if you have no internet connection on the WMS server, and 
you try to do a GetCapabilities request on the localhost address 
directly on the server, you get an error because the schema defined in 
the schemaLocation parameter can't be found. It seems to be the only 
test done for the validating part by default.

A JAXBException is thrown when the marshalling or unmarshalling process 
could not succeed, for example when the classes given to the JAXBContext 
are not enough to parse the XML file. But I don't know any subclasses 
for that exception.

Cédric.

Le 20/05/2010 15:03, sorel a écrit :
> Hi,
>
> I can't go any further on this topic, my knowledge about JAXB is 
> limited and I don't know if some of thoses
> verifications are done by it and if it already return subclasses of 
> jaxbException for each type of parsing errors.
> If not, making several passes before parsing will requiere some work 
> and time (I can't estimate).
> I'll let cedric bring mode details if he knows.
>
> johann sorel
>
>
> Jon Blower wrote:
>> Hi Johann,
>>
>> I agree that a general XmlParseException would be a good idea 
>> (perhaps with a subclass indicating a failure of an XML doc to 
>> validate with its own schema?)
>>
>>>> 3. An exception that is thrown when the server returns a WMS Exception
>>>> (e.g. CurrentUpdateSequence). In this case the server will return 
>>>> an XML
>>>> document containing the exception, which Java code should translate 
>>>> into
>>>> a checked exception.
>>> I'm not sure we can do a distinction between 2 and 3 since the 
>>> stream is directly send to the parser.
>>
>> In similar code in the past, we have taken the XML stream and tried 
>> to validate it against the Capabilities schema.  If this works, we 
>> parse it as Capabilities.  If not, we validate against the XML 
>> exceptions schema.  If this works, we convert the XML doc to a Java 
>> exception and throw it.  If this doesn't work, we throw an exception 
>> indicating a failure to parse.  Can you use the same approach?  It's 
>> very important for cache control to be able to handle exception 
>> documents from the server, since the server indicates "Document not 
>> changed" by sending a CurrentUpdateSequence exception.  (Personally I 
>> think this is a little crazy, but it's in the spec...)
>>
>> Cheers, Jon
>
> _______________________________________________
> Geotoolkit mailing list
> Geotoolkit at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/geotoolkit
>
>



More information about the Geotoolkit mailing list