0

I want to use GeoNetwork CSW HTTP services from a full Java stack client, and not web client, mainly to use HTTP transactional service.

I'm always redirected on the login HTML page after making a post login request with the proper credential. I receive session id cookies correctly, and I provide it to next level transactional POST request, but I always receive the login HTML page as answer.

My use case is to fill up the CSW catalog in a programmatic way, and not using the web sheet.

Does any tutorial exist on that way of working with GeoNetwork CSW?

1

2 Answers 2

2

Recently, I feel, I had a similar problem, connecting to the GeoNetwork q-interface. The question is posted here.

Maybe it helps to review this and my own answer about my findings.

My problem was, that GeoNetwork does a couple of redirects when calling the authorization endpoint. Somehow, I wasn't following them correctly.

After all, I ended up calling http://localhost:8080/geonetwork/srv/eng/catalog.signin to receive a session id, which I can use in turn to access the private datasets.

However, I still use credentials in every request (which are validated against the mentioned endpoint) but the session id should be valid too.

I now also use this in a setting to call GeoNetwork CSW endpoint.

1

If you want to use Java in order to implement a CSW client use the following library

https://github.com/Geomatys/geotoolkit/tree/master/modules/clients/geotk-client-csw/src/main/java/org/geotoolkit/csw

A simple example of a CSW GetRecords request with a *CQL filter would be the following:

        /** The csw server. */
        private final CatalogServicesClient cswServer;
               ...
        log.info("[CSWClient] getRecords - Constructing request...");
               ...
        final GetRecordsRequest getRecords = cswServer.createGetRecords();

        // gmd:MD_Metadata or csw:Record
        getRecords.setTypeNames("gmd:MD_Metadata");

        // CQL_TEXT or FILTER
        getRecords.setConstraintLanguage("CQL_TEXT");

        getRecords.setConstraintLanguageVersion("1.1.0");

        getRecords.setElementSetName(ElementSetType.FULL);

        // OUTPUT FORMAT
        getRecords.setOutputFormat("application/xml");

        // OUTPUT SCHEMA
        // DC: http://www.opengis.net/cat/csw/2.0.2 or
        // ISO: http://www.isotc211.org/2005/gmd
        getRecords.setOutputSchema(os.value());

        // HITS or VALIDATE or RESULTS
        getRecords.setResultType(ResultType.RESULTS);

        getRecords.setMaxRecords(config.getMaxRecordsRequested());

        getRecords.setConstraint("<QUERY>");

*CQL is the Common Query Language

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.