[geotk] Request WFS-Server with basic autentication

johann sorel johann.sorel at geomatys.com
Thu Aug 10 02:13:22 PDT 2017


Hello,

Note : For future questions please always continue to forward the mails 
to the geotoolkit mailing list, I am not the only one who might answer.

About eclipse, I can't help you sorry, the last time I used it was 
something like 8 years ago.

You can find an example of pom.xml in the demo module of geotoolkit
https://github.com/Geomatys/geotoolkit/tree/master/demos/geotk-demo-samples

And there is a demo for WFS :
https://github.com/Geomatys/geotoolkit/blob/master/demos/geotk-demo-samples/src/main/java/org/geotoolkit/pending/demo/clients/wfs/WFSClientDemo.java


johann




On 10/08/2017 10:54, Hebler, Christoph wrote:
>
> Hi Johann,
>
> many thanks for your response to my question and excuse me to answer 
> that late, but I was on holiday the last 3 weeks and in before there 
> was not enough time to test and answer.
>
> Unfortunately I do not get it run. Maybe I am also not experienced 
> enough with maven.
>
> Would it be possible that you give me some more hints?
>
> Since this is a free WFS-Server let’s say I want to perform this query 
> (which works within SoapUI):
>
> http://sla.niedersachsen.de/landentwicklung/land-d3/services?SERVICE=WFS&VERSION=1.1.0&REQUEST=GetFeature&TYPENAME=app:verfahrensart_ab
>
> I know this is without basic-authentication, but may be it is better 
> to get an example without authentication run.
>
> My setup is an empty eclipse project created by New àproject… à“maven 
> project” with type “maven-archetype-quickstart” version 1.1
>
> Would it be possible that you give me some hints how the POM-file has 
> to look like and a short “main-class” containing the needed code like 
> below to realise the
>
> query from the URL above?
>
> Many many thanks in advance for your help.
>
> Kind regards,
>
> Christoph
>
> *From:*johann sorel [mailto:johann.sorel at geomatys.com]
> *Sent:* Tuesday, July 04, 2017 9:39 AM
> *To:* Hebler, Christoph; geotoolkit at lists.osgeo.org
> *Subject:* Re: [geotk] Request WFS-Server with basic autentication
>
> Hello,
>
> Aside from the WebFeatureClient creation, it works the same as any 
> other FeatureStore.
>
> This code should do what you want :
>
> ------------------------------------------------------------------
> final URL url = new URL("http://..." <http://...>);
> final ClientSecurity security = new 
> BasicAuthenticationSecurity("user", "password");
> final boolean usePost = true;
> final FeatureStore store = new WebFeatureClient(url, security, 
> WFSVersion.v200, usePost);
>
> for (GenericName name : store.getNames()) {
>     final Filter filter = CQL.parseFilter("ATT_TYPE = 12");
>     final Query query = QueryBuilder.filtered(name,filter);
>     final FeatureReader reader = store.getFeatureReader(query);
>     while (reader.hasNext()) {
>         final Feature feature = reader.next();
>         System.out.println(feature);
>     }
>     reader.close();
> }
> ------------------------------------------------------------------
>
> Johann Sorel
>
> On 04/07/2017 08:31, Hebler, Christoph wrote:
>
>     Hello,
>
>     I am trying to request one special “typename” from a given
>     WFS-Server, but I am not able to get it.
>
>     Maybe someone of you is so kind to give me a working example?
>
>     Situation:
>
>     -using geotoolkit version 4.0.3
>
>     -trying to request a WFS-Server
>
>     -WFS-Server is secured with basic authentication (I assume this is
>     where I fail)
>
>     -WFS request request version 2.0.0 preferred (but 1.1.0 is
>     possible too)
>
>     -(if possible: using HTTP POST to request)
>
>     Both of the below XML-requests work within SoapUI:
>
>     <?xml version="1.0" encoding="UTF-8"?>
>
>     <wfs:GetFeature
>
>           xmlns="http://www.opengis.net/wfs" <http://www.opengis.net/wfs>
>
>           xmlns:abc="http://www.abc-online.com/namespaces/abc/"
>     <http://www.abc-online.com/namespaces/abc/>
>
>           xmlns:ogc="http://www.opengis.net/ogc"
>     <http://www.opengis.net/ogc>
>
>           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     <http://www.w3.org/2001/XMLSchema-instance>
>
>           xmlns:gml="http://www.opengis.net/gml"
>     <http://www.opengis.net/gml>
>
>           xmlns:wfs="http://www.opengis.net/wfs"
>     <http://www.opengis.net/wfs>
>
>     service="WFS" version="1.1.0"
>
>           outputFormat="text/xml; subtype=gml/3.2.1" handle="">
>
>           <wfs:Query typeName="abc:RequestedType">
>
>                 <ogc:Filter>
>
>     <ogc:PropertyIsEqualTo>
>
>     <ogc:PropertyName>abc:RequestedType/abc:identifier</ogc:PropertyName>
>
>     <ogc:Literal>1234</ogc:Literal>
>
>            </ogc:PropertyIsEqualTo>
>
>                 </ogc:Filter>
>
>           </wfs:Query>
>
>     </wfs:GetFeature>
>
>     <?xml version="1.0" encoding="UTF-8"?>
>
>     <wfs:GetFeature
>
>        service="WFS"
>
>        version="2.0.0"
>
>        outputFormat="text/xml; subtype=gml/3.2.1" handle=""
>
>        xmlns:abc="http://www.abc-online.com/namespaces/abc/"
>     <http://www.abc-online.com/namespaces/abc/>
>
>        xmlns:wfs="http://www.opengis.net/wfs/2.0"
>     <http://www.opengis.net/wfs/2.0>
>
>        xmlns:fes="http://www.opengis.net/fes/2.0"
>     <http://www.opengis.net/fes/2.0>
>
>        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>     <http://www.w3.org/2001/XMLSchema-instance>
>
>     > 
>
>        <wfs:Query typeNames=”abc:RequestedType">
>
>          <fes:Filter>
>
>     <fes:PropertyIsEqualTo>
>
>     <fes:ValueReference>abc:RequestedType/abc:identifier</fes:ValueReference>
>
>     <fes:Literal>1234</fes:Literal>
>
>     </fes:PropertyIsEqualTo>
>
>          </fes:Filter>
>
>        </wfs:Query>
>
>     </wfs:GetFeature>
>
>     Would it be possible to post a working java code example to
>     realize such a request, starting with the creation of the
>     WebFeatureClient (if that´s the right class), using basic
>     authentication, setting the Query with typeName and Filter
>
>     including the lines to send that request to the WFS-Server?
>
>     Maybe a link to the documentation where this is described would
>     also help, but unfortunately I did not find any documentation or
>     example code explaining this situation executing a WFS request
>     including basic authentication and setting typename and filter.
>
>     Thanks a lot in advance!
>
>     Regards,
>
>     Chris
>
>
>
>
>     _______________________________________________
>
>     Geotoolkit mailing list
>
>     Geotoolkit at lists.osgeo.org <mailto:Geotoolkit at lists.osgeo.org>
>
>     https://lists.osgeo.org/mailman/listinfo/geotoolkit
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20170810/f9dcc716/attachment-0001.html>


More information about the Geotoolkit mailing list