[geotk] Request WFS-Server with basic autentication
johann sorel
johann.sorel at geomatys.com
Tue Jul 4 00:38:35 PDT 2017
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://...");
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"
>
> xmlns:abc="http://www.abc-online.com/namespaces/abc/"
>
> xmlns:ogc="http://www.opengis.net/ogc"
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> xmlns:gml="http://www.opengis.net/gml"
>
> xmlns: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/"
>
> xmlns:wfs="http://www.opengis.net/wfs/2.0"
>
> xmlns:fes="http://www.opengis.net/fes/2.0"
>
> xmlns:xsi="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
> https://lists.osgeo.org/mailman/listinfo/geotoolkit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geotoolkit/attachments/20170704/f8583657/attachment-0001.html>
More information about the Geotoolkit
mailing list