This is an automated email from the ASF dual-hosted git repository.

asf-gitbox-commits pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 8c3355d32c feat(Web): add core classes for web client api
8c3355d32c is described below

commit 8c3355d32c17359e3826395bcff844423dbe1b3d
Author: jsorel <[email protected]>
AuthorDate: Mon Nov 16 09:41:21 2026 +0100

    feat(Web): add core classes for web client api
---
 .../org.apache.sis.metadata/main/module-info.java  |   1 +
 incubator/build.gradle.kts                         |   2 +
 .../main/module-info.java                          |  10 +
 .../sis/storage/web/openapi/AbstractOpenApi.java   |  87 +++++
 .../storage/web/openapi/OpenApiConfiguration.java  | 134 +++++++
 .../storage/web/openapi/RFC3339JavaTimeModule.java | 173 +++++++++
 .../sis/storage/web/openapi/package-info.java      |  45 +++
 .../sis/storage/web/service/AbstractService.java   | 286 ++++++++++++++
 .../storage/web/service/JacksonBodyHandler.java    |  91 +++++
 .../apache/sis/storage/web/service/Pair.java}      |  45 ++-
 .../storage/web/service/ServiceConfiguration.java  | 417 +++++++++++++++++++++
 .../sis/storage/web/service/ServiceException.java  |  96 +++++
 .../sis/storage/web/service/ServiceRequest.java    |  68 ++++
 .../web/service/UncheckedServiceException.java     |  96 +++++
 .../sis/storage/web/service/package-info.java}     |  34 +-
 15 files changed, 1568 insertions(+), 17 deletions(-)

diff --git a/endorsed/src/org.apache.sis.metadata/main/module-info.java 
b/endorsed/src/org.apache.sis.metadata/main/module-info.java
index 9a7defc13f..bad6619ab6 100644
--- a/endorsed/src/org.apache.sis.metadata/main/module-info.java
+++ b/endorsed/src/org.apache.sis.metadata/main/module-info.java
@@ -86,6 +86,7 @@ module org.apache.sis.metadata {
             org.apache.sis.storage.json,        // In the "incubator" 
sub-project.
             org.apache.sis.storage.shapefile,   // In the "incubator" 
sub-project.
             org.apache.sis.storage.hdf,         // In the "incubator" 
sub-project.
+            org.apache.sis.storage.ogcwxs,      // In the "incubator" 
sub-project.
             org.apache.sis.cql;                 // In the "incubator" 
sub-project.
 
     exports org.apache.sis.metadata.internal.shared to
diff --git a/incubator/build.gradle.kts b/incubator/build.gradle.kts
index 0f93136da1..9581c4614c 100644
--- a/incubator/build.gradle.kts
+++ b/incubator/build.gradle.kts
@@ -62,6 +62,8 @@ dependencies {
     implementation(group = "com.fasterxml.jackson.core", name = 
"jackson-core",        version = "2.22.1")
     implementation(group = "com.fasterxml.jackson.core", name = 
"jackson-annotations", version = "2.22")
     implementation(group = "com.fasterxml.jackson.core", name = 
"jackson-databind",    version = "2.22.1")
+    implementation(group = "com.fasterxml.jackson.datatype", name = 
"jackson-datatype-jsr310", version = "2.22.1")
+    implementation(group = "org.openapitools",           name = 
"jackson-databind-nullable", version = "0.2.6")
     implementation(group = "org.antlr",                  name = 
"antlr4-maven-plugin", version = "4.13.2")
     implementation(group = "org.xerial",                 name = "sqlite-jdbc", 
        version = "3.45.1.0")
     implementation(group = "org.apache.xmlgraphics",     name = 
"batik-bridge",        version = "1.19") {
diff --git a/incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java
index 3cc8d1f841..8ec5833b92 100644
--- a/incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java
+++ b/incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java
@@ -24,7 +24,17 @@
 module org.apache.sis.storage.ogcwxs {
     // Dependencies used in public API.
     requires transitive org.apache.sis.storage;
+    requires transitive java.net.http;
+
+    // Dependencies internal to the implementation.
+    requires com.fasterxml.jackson.core;
+    requires com.fasterxml.jackson.annotation;
+    requires com.fasterxml.jackson.databind;
+    requires com.fasterxml.jackson.datatype.jsr310;
+    requires org.openapitools.jackson.nullable;
 
     // Uncomment when the package contains at least one class.
     // exports org.apache.sis.storage.ogcwxs;
+    exports org.apache.sis.storage.web.service;
+    exports org.apache.sis.storage.web.openapi;
 }
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/AbstractOpenApi.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/AbstractOpenApi.java
new file mode 100644
index 0000000000..03192cb2cb
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/AbstractOpenApi.java
@@ -0,0 +1,87 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.openapi;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.UncheckedIOException;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.function.Supplier;
+import org.apache.sis.storage.web.service.AbstractService;
+import org.apache.sis.storage.web.service.ServiceRequest;
+
+/**
+ *
+ * @author Johann Sorel (Geomatys)
+ */
+public abstract class AbstractOpenApi extends AbstractService {
+
+    protected final ObjectMapper objectMapper;
+
+    public AbstractOpenApi(OpenApiConfiguration apiClient) {
+        super(apiClient);
+        objectMapper = apiClient.getObjectMapper();
+    }
+
+    @Override
+    public OpenApiConfiguration getConfiguration() {
+        return (OpenApiConfiguration) super.getConfiguration();
+    }
+
+    protected <T> ServiceRequest<Supplier<T>> 
requestAsJson(HttpRequest.Builder request, Class<T> valueClass) {
+        return super.requestAsJson(request, objectMapper, valueClass);
+    }
+
+    protected <T> ServiceRequest<Supplier<T>> 
requestAsJson(HttpRequest.Builder request, TypeReference<T> valueClass) {
+        return super.requestAsJson(request, objectMapper, valueClass);
+    }
+
+    protected <T> ServiceRequest<Supplier<T>> 
requestAsJson(HttpRequest.Builder request, JavaType valueClass) {
+        return super.requestAsJson(request, objectMapper, valueClass);
+    }
+
+    /**
+     * Deserializes a specific named field from the JSON response object.
+     * Use when the API returns a thin envelope (e.g. {@code 
{"versions":[...]}})
+     * and the caller needs only the inner value as a standard Java type.
+     *
+     * @param <T>       target type
+     * @param request   prepared request builder
+     * @param fieldName JSON field name to extract from the root object
+     * @param valueType Jackson TypeReference for the target type
+     * @return configured service request
+     */
+    protected <T> ServiceRequest<Supplier<T>> 
requestAsJsonField(HttpRequest.Builder request, String fieldName, 
TypeReference<T> valueType) {
+        final HttpResponse.BodyHandler<Supplier<T>> bodyHandler = responseInfo 
->
+            HttpResponse.BodySubscribers.mapping(
+                HttpResponse.BodySubscribers.ofInputStream(),
+                is -> {
+                    try {
+                        final T value = objectMapper.convertValue(
+                            objectMapper.readTree(is).get(fieldName),
+                            valueType);
+                        return () -> value;
+                    } catch (IOException e) {
+                        throw new UncheckedIOException(e);
+                    }
+                });
+        return request(request, bodyHandler);
+    }
+}
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/OpenApiConfiguration.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/OpenApiConfiguration.java
new file mode 100644
index 0000000000..159317f6f3
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/OpenApiConfiguration.java
@@ -0,0 +1,134 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.openapi;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import java.io.InputStream;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.time.Duration;
+import java.util.function.Consumer;
+import org.apache.sis.storage.web.service.ServiceConfiguration;
+import org.openapitools.jackson.nullable.JsonNullableModule;
+
+/**
+ * Configuration and utility class for OpenAPI clients.
+ *
+ * <p>
+ * This class can be constructed and modified, then used to instantiate the
+ * various API classes. The API classes use the settings in this class to
+ * configure themselves, but otherwise do not store a link to this class.</p>
+ *
+ * <p>
+ * This class is mutable and not synchronized, so it is not thread-safe. The 
API
+ * classes generated from this are immutable and thread-safe.</p>
+ *
+ * <p>
+ * The setter methods of this class return the current object to facilitate a
+ * fluent style of configuration.</p>
+ */
+public final class OpenApiConfiguration extends ServiceConfiguration {
+
+    private final ObjectMapper mapper;
+
+    protected OpenApiConfiguration(HttpClient.Builder builder, String scheme,
+            String host, int port, String basePath,
+            Consumer<HttpRequest.Builder> interceptor,
+            Consumer<HttpResponse<?>> responseInterceptor,
+            Duration readTimeout, Duration connectTimeout, ObjectMapper 
mapper) {
+        super(builder, scheme, host, port, basePath, interceptor,
+                responseInterceptor, readTimeout, connectTimeout);
+        this.mapper = mapper;
+    }
+
+    /**
+     * Get a copy of the current {@link ObjectMapper}.
+     *
+     * @return A copy of the current object mapper.
+     */
+    public ObjectMapper getObjectMapper() {
+        return mapper.copy();
+    }
+
+    public static ObjectMapper createDefaultObjectMapper() {
+        ObjectMapper mapper = new ObjectMapper();
+        mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+        mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, 
false);
+        mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, 
false);
+        mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
+        mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING);
+        mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
+        
mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE);
+        mapper.registerModule(new JavaTimeModule());
+        mapper.registerModule(new JsonNullableModule());
+        mapper.registerModule(new RFC3339JavaTimeModule());
+        return mapper;
+    }
+
+    public static OpenApiConfiguration.Builder builder() {
+        return new OpenApiConfiguration.Builder();
+    }
+
+    /**
+     *
+    * <p>
+    * This class can be constructed and modified, then used to instantiate the
+    * various API classes. The API classes use the settings in this class to
+    * configure themselves, but otherwise do not store a link to this 
class.</p>
+    *
+    * <p>
+    * This class is mutable and not synchronized, so it is not thread-safe. 
The API
+    * classes generated from this are immutable and thread-safe.</p>
+     */
+    public static class Builder extends ServiceConfiguration.Builder<Builder> {
+
+        private ObjectMapper mapper = createDefaultObjectMapper();
+
+        /**
+         * Set a custom {@link ObjectMapper} to serialize and deserialize the
+         * request and response bodies.
+         *
+         * @param mapper Custom object mapper.
+         * @return This object.
+         */
+        public Builder setObjectMapper(ObjectMapper mapper) {
+            this.mapper = mapper;
+            return this;
+        }
+
+        /**
+         * Get a copy of the current {@link ObjectMapper}.
+         *
+         * @return A copy of the current object mapper.
+         */
+        public ObjectMapper getObjectMapper() {
+            return mapper.copy();
+        }
+
+        @Override
+        public OpenApiConfiguration build() {
+            return new OpenApiConfiguration(builder, scheme, host, port, 
basePath,
+                    interceptor, responseInterceptor, readTimeout, 
connectTimeout, mapper);
+        }
+
+    }
+}
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/RFC3339JavaTimeModule.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/RFC3339JavaTimeModule.java
new file mode 100644
index 0000000000..b5317ddabd
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/RFC3339JavaTimeModule.java
@@ -0,0 +1,173 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.openapi;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.exc.InvalidFormatException;
+import java.time.Instant;
+import java.time.OffsetDateTime;
+import java.time.ZonedDateTime;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.util.StdDateFormat;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeFeature;
+import com.fasterxml.jackson.datatype.jsr310.deser.InstantDeserializer;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.FieldPosition;
+import java.text.ParsePosition;
+import java.time.ZoneId;
+import java.time.ZoneOffset;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+import java.time.temporal.Temporal;
+import java.time.temporal.TemporalAccessor;
+import java.util.Date;
+import java.util.GregorianCalendar;
+import java.util.TimeZone;
+import java.util.function.BiFunction;
+import java.util.function.Function;
+import org.apache.sis.temporal.LenientDateFormat;
+
+public final class RFC3339JavaTimeModule extends SimpleModule {
+
+    public RFC3339JavaTimeModule() {
+        super("RFC3339JavaTimeModule");
+        addDeserializer(Instant.class, RFC3339InstantDeserializer.INSTANT);
+        addDeserializer(OffsetDateTime.class, 
RFC3339InstantDeserializer.OFFSET_DATE_TIME);
+        addDeserializer(ZonedDateTime.class, 
RFC3339InstantDeserializer.ZONED_DATE_TIME);
+    }
+
+    public static final class RFC3339DateFormat extends DateFormat {
+
+        private static final TimeZone TIMEZONE_Z = TimeZone.getTimeZone("UTC");
+
+        private final StdDateFormat fmt = new StdDateFormat()
+                .withTimeZone(TIMEZONE_Z)
+                .withColonInTimeZone(true);
+
+        public RFC3339DateFormat() {
+            this.calendar = new GregorianCalendar();
+            this.numberFormat = new DecimalFormat();
+        }
+
+        @Override
+        public Date parse(String source) {
+            return parse(source, new ParsePosition(0));
+        }
+
+        @Override
+        public Date parse(String source, ParsePosition pos) {
+            return fmt.parse(source, pos);
+        }
+
+        @Override
+        public StringBuffer format(Date date, StringBuffer toAppendTo, 
FieldPosition fieldPosition) {
+            return fmt.format(date, toAppendTo, fieldPosition);
+        }
+
+        @Override
+        public Object clone() {
+            return super.clone();
+        }
+    }
+
+    public static final class RFC3339InstantDeserializer<T extends Temporal> 
extends InstantDeserializer<T> {
+
+        private final static boolean DEFAULT_NORMALIZE_ZONE_ID = 
JavaTimeFeature.NORMALIZE_DESERIALIZED_ZONE_ID.enabledByDefault();
+        private final static boolean 
DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
+        = 
JavaTimeFeature.ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS.enabledByDefault();
+
+        public static final RFC3339InstantDeserializer<Instant> INSTANT = new 
RFC3339InstantDeserializer<>(
+            Instant.class, DateTimeFormatter.ISO_INSTANT,
+            Instant::from,
+            a -> Instant.ofEpochMilli( a.value ),
+            a -> Instant.ofEpochSecond( a.integer, a.fraction ),
+            null,
+            true, // yes, replace zero offset with Z
+            DEFAULT_NORMALIZE_ZONE_ID,
+            DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
+        );
+
+        public static final RFC3339InstantDeserializer<OffsetDateTime> 
OFFSET_DATE_TIME = new RFC3339InstantDeserializer<>(
+            OffsetDateTime.class, DateTimeFormatter.ISO_OFFSET_DATE_TIME,
+            OffsetDateTime::from,
+            a -> OffsetDateTime.ofInstant( Instant.ofEpochMilli( a.value ), 
a.zoneId ),
+            a -> OffsetDateTime.ofInstant( Instant.ofEpochSecond( a.integer, 
a.fraction ), a.zoneId ),
+            (d, z) -> ( d.isEqual( OffsetDateTime.MIN ) || d.isEqual( 
OffsetDateTime.MAX ) ?
+            d :
+            d.withOffsetSameInstant( z.getRules().getOffset( 
d.toLocalDateTime() ) ) ),
+            true, // yes, replace zero offset with Z
+            DEFAULT_NORMALIZE_ZONE_ID,
+            DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
+        );
+
+        public static final RFC3339InstantDeserializer<ZonedDateTime> 
ZONED_DATE_TIME = new RFC3339InstantDeserializer<>(
+            ZonedDateTime.class, DateTimeFormatter.ISO_ZONED_DATE_TIME,
+            ZonedDateTime::from,
+            a -> ZonedDateTime.ofInstant( Instant.ofEpochMilli( a.value ), 
a.zoneId ),
+            a -> ZonedDateTime.ofInstant( Instant.ofEpochSecond( a.integer, 
a.fraction ), a.zoneId ),
+            ZonedDateTime::withZoneSameInstant,
+            false, // keep zero offset and Z separate since zones explicitly 
supported
+            DEFAULT_NORMALIZE_ZONE_ID,
+            DEFAULT_ALWAYS_ALLOW_STRINGIFIED_DATE_TIMESTAMPS
+        );
+
+        protected RFC3339InstantDeserializer(
+                Class<T> supportedType,
+                DateTimeFormatter formatter,
+                Function<TemporalAccessor, T> parsedToValue,
+                Function<InstantDeserializer.FromIntegerArguments, T> 
fromMilliseconds,
+                Function<InstantDeserializer.FromDecimalArguments, T> 
fromNanoseconds,
+                BiFunction<T, ZoneId, T> adjust,
+                boolean replaceZeroOffsetAsZ,
+                boolean normalizeZoneId,
+                boolean readNumericStringsAsTimestamp) {
+            super(
+                    supportedType,
+                    formatter,
+                    parsedToValue,
+                    fromMilliseconds,
+                    fromNanoseconds,
+                    adjust,
+                    replaceZeroOffsetAsZ,
+                    normalizeZoneId,
+                    readNumericStringsAsTimestamp
+            );
+        }
+
+        @Override
+        protected T _fromString(JsonParser p, DeserializationContext ctxt, 
String string0) throws IOException {
+            try {
+                return super._fromString(p, ctxt, string0.replace( ' ', 'T' ));
+            } catch (NumberFormatException | DateTimeParseException | 
InvalidFormatException e) {
+                //fallback on a tolerant parser
+                final Instant i = LenientDateFormat.parseInstantUTC(string0);
+                if (this == INSTANT) {
+                    return (T) i;
+                } else if (this == OFFSET_DATE_TIME) {
+                    return (T) i.atOffset(ZoneOffset.UTC);
+                } else if (this == ZONED_DATE_TIME) {
+                    return (T) i.atZone(ZoneId.systemDefault());
+                }
+                throw e;
+            }
+        }
+    }
+
+}
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/package-info.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/package-info.java
new file mode 100644
index 0000000000..ae16ac2192
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/openapi/package-info.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Bindings for OGC-API services for java 11 HttpClient.
+ *
+ * <p>
+ * Based bindings have been generated with 
https://github.com/OpenAPITools/openapi-generator
+ * then cleaned and simplified.
+ * <p>
+ * Exemple :
+ * <pre>
+ * OpenApiConfiguration conf = new OpenApiConfiguration();
+ * conf.setBasePath("https://server.com/service-openapi/";);
+ *
+ * ConformanceApi api = new ConformanceApi(conf);
+ * try {
+ *     ConfClasses result = api.getConformance("json");
+ *     System.out.println(result);
+ * } catch (ApiException e) {
+ *     System.err.println("Exception when calling 
ConformanceApi#getConformance");
+ *     System.err.println("Status code: " + e.getCode());
+ *     System.err.println("Reason: " + e.getResponseBody());
+ *     System.err.println("Response headers: " + e.getResponseHeaders());
+ *     e.printStackTrace();
+ * }
+ * </pre>
+ *
+ *
+ */
+package org.apache.sis.storage.web.openapi;
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/AbstractService.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/AbstractService.java
new file mode 100644
index 0000000000..78b2ea338e
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/AbstractService.java
@@ -0,0 +1,286 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.service;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URLEncoder;
+import java.net.http.HttpClient;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.net.http.HttpResponse.BodyHandler;
+import static java.nio.charset.StandardCharsets.UTF_8;
+import java.time.OffsetDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringJoiner;
+import java.util.concurrent.CompletableFuture;
+import java.util.function.BiConsumer;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+/**
+ *
+ * @author Johann Sorel (Geomatys)
+ */
+public abstract class AbstractService implements AutoCloseable {
+
+    protected final ServiceConfiguration config;
+    protected final HttpClient httpClient;
+
+    public AbstractService(ServiceConfiguration apiClient) {
+        this.config = apiClient;
+        httpClient = apiClient.createHttpClient();
+    }
+
+    /**
+     * @return parameters used by this service;
+     */
+    public ServiceConfiguration getConfiguration() {
+        return config;
+    }
+
+    protected HttpResponse<InputStream> send(HttpRequest.Builder 
requestBuilder) throws ServiceException {
+        final HttpRequest request = requestBuilder.build();
+        try {
+            final HttpResponse<InputStream> response = httpClient.send(
+                    request,
+                    HttpResponse.BodyHandlers.ofInputStream());
+            if (config.responseInterceptor != null) {
+                config.responseInterceptor.accept(response);
+            }
+            if (response.statusCode() / 100 != 2) {
+                throw toServiceException(request.uri().getPath(), response);
+            }
+            return response;
+        } catch (IOException e) {
+            throw new ServiceException(e);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            throw new ServiceException(e);
+        }
+    }
+
+    protected CompletableFuture<HttpResponse<InputStream>> 
sendAsync(HttpRequest.Builder requestBuilder) throws ServiceException {
+        final HttpRequest request = requestBuilder.build();
+        final CompletableFuture<HttpResponse<InputStream>> response = 
httpClient.sendAsync(
+                request,
+                HttpResponse.BodyHandlers.ofInputStream());
+        if (config.responseInterceptor != null) {
+            response.whenComplete(new BiConsumer<HttpResponse<InputStream>, 
Throwable>() {
+                @Override
+                public void accept(HttpResponse<InputStream> t, Throwable u) {
+                    config.responseInterceptor.accept(t);
+                }
+            });
+        }
+        return response;
+    }
+
+    protected <T> HttpResponse<T> send(HttpRequest request, BodyHandler<T> 
bodyHandler) throws ServiceException {
+        try {
+            final HttpResponse<T> response = 
httpClient.send(request,bodyHandler);
+            if (config.responseInterceptor != null) {
+                config.responseInterceptor.accept(response);
+            }
+            if (response.statusCode() / 100 != 2) {
+                throw toServiceException(request.uri().getPath(), response);
+            }
+            return response;
+        } catch (IOException e) {
+            throw new ServiceException(e);
+        } catch (InterruptedException e) {
+            Thread.currentThread().interrupt();
+            throw new ServiceException(e);
+        }
+    }
+
+    protected <T> CompletableFuture<HttpResponse<T>> sendAsync(HttpRequest 
request, BodyHandler<T> bodyHandler) {
+        final CompletableFuture<HttpResponse<T>> response = 
httpClient.sendAsync(
+                request,
+                bodyHandler);
+        if (config.responseInterceptor != null) {
+            response.whenComplete((HttpResponse<T> t, Throwable u) -> {
+                config.responseInterceptor.accept(t);
+            });
+        }
+        return response;
+    }
+
+    protected <T> ServiceRequest<T> request(HttpRequest.Builder request, 
BodyHandler<T> bodyHandler) {
+        return new ServiceRequest<>(this, request, bodyHandler);
+    }
+
+    protected URI toUri(String localPath, List<Pair> queryParams) {
+        final String fullPath = localPath == null ? config.baseUri : 
config.baseUri + localPath;
+
+        if (queryParams != null && !queryParams.isEmpty()) {
+            final StringJoiner queryJoiner = new StringJoiner("&");
+            queryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + 
p.getValue()));
+            return URI.create(fullPath + '?' + queryJoiner.toString());
+        } else {
+            return URI.create(fullPath);
+        }
+    }
+
+    /**
+     * Set request timeout and interceptor.
+     */
+    protected HttpRequest.Builder setConfig(HttpRequest.Builder 
requestBuilder) {
+        if (config.readTimeout != null) 
requestBuilder.timeout(config.readTimeout);
+        if (config.requestInterceptor != null) 
config.requestInterceptor.accept(requestBuilder);
+        return requestBuilder;
+    }
+
+    protected ServiceException toServiceException(String operationId, 
HttpResponse<?> response) throws IOException {
+        String body = response.body() == null ? null : 
response.body().getClass().getName();
+        String message = formatExceptionMessage(operationId, 
response.statusCode(), body);
+        return new ServiceException(response.statusCode(), message, 
response.headers(), body);
+    }
+
+    private String formatExceptionMessage(String operationId, int statusCode, 
String body) {
+        if (body == null || body.isEmpty()) {
+            body = "[no body]";
+        }
+        return operationId + " call failed with: " + statusCode + " - " + body;
+    }
+
+    @Override
+    public void close() throws Exception {
+        // HTTPClient becomes closeable in JDK 21
+        if (httpClient instanceof AutoCloseable) {
+            ((AutoCloseable)httpClient).close();
+        }
+    }
+
+    public static String valueToString(Object value) {
+        if (value == null) {
+            return "";
+        }
+        if (value instanceof OffsetDateTime) {
+            return ((OffsetDateTime) 
value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
+        }
+        return value.toString();
+    }
+
+    /**
+     * URL encode a string in the UTF-8 encoding.
+     *
+     * @param s String to encode.
+     * @return URL-encoded representation of the input string.
+     */
+    public static String urlEncode(String s) {
+        return URLEncoder.encode(s, UTF_8).replaceAll("\\+", "%20");
+    }
+
+    /**
+     * Convert a URL query name/value parameter to a list of encoded
+     * {@link Pair} objects.
+     *
+     * <p>
+     * The value can be null, in which case an empty list is returned.</p>
+     *
+     * @param name The query name parameter.
+     * @param value The query value, which may not be a collection but may be
+     * null.
+     * @return A singleton list of the {@link Pair} objects representing the
+     * input parameters, which is encoded for use in a URL. If the value is
+     * null, an empty list is returned.
+     */
+    public static List<Pair> toPairs(String name, Object value) {
+        if (name == null || name.isEmpty() || value == null) {
+            return Collections.emptyList();
+        }
+        return Collections.singletonList(new Pair(urlEncode(name), 
urlEncode(valueToString(value))));
+    }
+
+    /**
+     * Convert a URL query name/collection parameter to a list of encoded
+     * {@link Pair} objects.
+     *
+     * @param collectionFormat The swagger collectionFormat string (csv, tsv,
+     * etc).
+     * @param name The query name parameter.
+     * @param values A collection of values for the given query name, which may
+     * be null.
+     * @return A list of {@link Pair} objects representing the input 
parameters,
+     * which is encoded for use in a URL. If the values collection is null, an
+     * empty list is returned.
+     */
+    public static List<Pair> toPairs(String collectionFormat, String name, 
Collection<?> values) {
+        if (name == null || name.isEmpty() || values == null || 
values.isEmpty()) {
+            return Collections.emptyList();
+        }
+
+        // get the collection format (default: csv)
+        String format = collectionFormat == null || collectionFormat.isEmpty() 
? "csv" : collectionFormat;
+
+        // create the params based on the collection format
+        if ("multi".equals(format)) {
+            return values.stream()
+                    .map(value -> new Pair(urlEncode(name), 
urlEncode(valueToString(value))))
+                    .collect(Collectors.toList());
+        }
+
+        String delimiter;
+        switch (format) {
+            case "csv":
+                delimiter = urlEncode(",");
+                break;
+            case "ssv":
+                delimiter = urlEncode(" ");
+                break;
+            case "tsv":
+                delimiter = urlEncode("\t");
+                break;
+            case "pipes":
+                delimiter = urlEncode("|");
+                break;
+            default:
+                throw new IllegalArgumentException("Illegal collection format: 
" + collectionFormat);
+        }
+
+        StringJoiner joiner = new StringJoiner(delimiter);
+        for (Object value : values) {
+            joiner.add(urlEncode(valueToString(value)));
+        }
+
+        return Collections.singletonList(new Pair(urlEncode(name), 
joiner.toString()));
+    }
+
+    protected <T> ServiceRequest<Supplier<T>> 
requestAsJson(HttpRequest.Builder request, ObjectMapper objectMapper, Class<T> 
valueClass) {
+        return new ServiceRequest<>(this, request, new 
JacksonBodyHandler<>(objectMapper, valueClass));
+    }
+
+    protected <T> ServiceRequest<Supplier<T>> 
requestAsJson(HttpRequest.Builder request, ObjectMapper objectMapper, 
TypeReference<T> valueClass) {
+        return new ServiceRequest<>(this, request, new 
JacksonBodyHandler<>(objectMapper, valueClass));
+    }
+
+    protected <T> ServiceRequest<Supplier<T>> 
requestAsJson(HttpRequest.Builder request, ObjectMapper objectMapper, JavaType 
valueClass) {
+        return new ServiceRequest<>(this, request, new 
JacksonBodyHandler<>(objectMapper, valueClass));
+    }
+
+    public static String getContentEncoding(HttpResponse<?> httpResponse) {
+        return 
httpResponse.headers().firstValue("Content-Encoding").orElse("");
+    }
+}
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/JacksonBodyHandler.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/JacksonBodyHandler.java
new file mode 100644
index 0000000000..14db186f4b
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/JacksonBodyHandler.java
@@ -0,0 +1,91 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.service;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UncheckedIOException;
+import java.net.http.HttpResponse;
+import java.net.http.HttpResponse.BodySubscriber;
+import java.net.http.HttpResponse.BodySubscribers;
+import java.nio.charset.StandardCharsets;
+import java.util.function.Supplier;
+import java.util.zip.GZIPInputStream;
+
+/**
+ *
+ * @author Johann Sorel (Geomatys)
+ * @see 
https://docs.oracle.com/en/java/javase/25/docs/api/java.net.http/java/net/http/HttpResponse.BodySubscribers.html#mapping(java.net.http.HttpResponse.BodySubscriber,java.util.function.Function)
+ */
+public final class JacksonBodyHandler<W> implements 
HttpResponse.BodyHandler<Supplier<W>> {
+
+    private final ObjectMapper mapper;
+    private final JavaType ref;
+
+    public JacksonBodyHandler(ObjectMapper mapper, Class<W> valueClass) {
+        this(mapper, (JavaType)((valueClass == null) ? null : 
mapper.constructType(valueClass)));
+    }
+
+    public JacksonBodyHandler(ObjectMapper mapper, TypeReference<W> ref) {
+        this(mapper, (JavaType)((ref == null) ? null : 
mapper.constructType(ref)));
+    }
+
+    public JacksonBodyHandler(ObjectMapper mapper, JavaType ref) {
+        this.mapper = mapper;
+        this.ref = ref;
+    }
+
+    @Override
+    public HttpResponse.BodySubscriber<Supplier<W>> 
apply(HttpResponse.ResponseInfo responseInfo) {
+        final String contentEncoding = 
responseInfo.headers().firstValue("Content-Encoding").orElse("");
+        return asJSON(contentEncoding);
+    }
+
+    private BodySubscriber<Supplier<W>> asJSON(String contentEncoding) {
+        final BodySubscriber<InputStream> upstream = 
BodySubscribers.ofInputStream();
+
+        return BodySubscribers.mapping(upstream,
+            (InputStream is) -> () -> {
+                try (InputStream in = is) {
+                    InputStream di = in;
+                    if ("gzip".equals(contentEncoding)) {
+                        di = new GZIPInputStream(di);
+                    }
+                    final W body;
+                    if (ref == null) {
+                        // Drain the InputStream
+                        while (in.read() != -1) {
+                            // Ignore
+                        }
+                        body = null;
+                    } else {
+                        byte[] blob = di.readAllBytes();
+                        final String str = new String(blob, 
StandardCharsets.UTF_8);
+                        body = mapper.readValue(str, ref);
+                    }
+                    return body;
+
+                } catch (IOException e) {
+                    throw new UncheckedIOException(e);
+                }
+            });
+    }
+
+}
diff --git a/incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/Pair.java
similarity index 53%
copy from incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java
copy to 
incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/Pair.java
index 3cc8d1f841..d5408d6555 100644
--- a/incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/Pair.java
@@ -14,17 +14,48 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.sis.storage.web.service;
 
 /**
- * Data stores for the <abbr>OGC</abbr> web services of the W*S family
- * (<abbr>WMS</abbr>, <abbr>WMTS</abbr>, <abbr>WFS</abbr>, <abbr>WCS</abbr>, 
…).
+ * Key value pair.
  *
  * @author Johann Sorel (Geomatys)
  */
-module org.apache.sis.storage.ogcwxs {
-    // Dependencies used in public API.
-    requires transitive org.apache.sis.storage;
+public final class Pair {
 
-    // Uncomment when the package contains at least one class.
-    // exports org.apache.sis.storage.ogcwxs;
+    private String name = "";
+    private String value = "";
+
+    public Pair(String name, String value) {
+        setName(name);
+        setValue(value);
+    }
+
+    private void setName(String name) {
+        if (!isValidString(name)) {
+            return;
+        }
+
+        this.name = name;
+    }
+
+    private void setValue(String value) {
+        if (!isValidString(value)) {
+            return;
+        }
+
+        this.value = value;
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public String getValue() {
+        return this.value;
+    }
+
+    private boolean isValidString(String arg) {
+        return arg != null;
+    }
 }
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceConfiguration.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceConfiguration.java
new file mode 100644
index 0000000000..a2aaa4013e
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceConfiguration.java
@@ -0,0 +1,417 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.service;
+
+import java.io.InputStream;
+import java.net.Authenticator;
+import java.net.PasswordAuthentication;
+import java.net.URI;
+import java.net.http.HttpClient;
+import java.net.http.HttpConnectTimeoutException;
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.time.Duration;
+import java.util.function.Consumer;
+
+/**
+ * Configuration elements of an API client.
+ *
+ * <p>
+ * This class is immutable and thread-safe.</p>
+ *
+ * <p>
+ * The setter methods of this class return the current object to facilitate a
+ * fluent style of configuration.</p>
+ */
+public class ServiceConfiguration {
+
+    private static final String DEFAULT_BASE_URI = "http://localhost";;
+
+    private final HttpClient.Builder builder;
+    final String scheme;
+    final String host;
+    final int port;
+    final String basePath;
+    final Consumer<HttpRequest.Builder> requestInterceptor;
+    final Consumer<HttpResponse<?>> responseInterceptor;
+    final Duration readTimeout;
+    final Duration connectTimeout;
+    final String baseUri;
+
+    protected ServiceConfiguration(HttpClient.Builder builder, String scheme,
+            String host, int port, String basePath,
+            Consumer<HttpRequest.Builder> interceptor,
+            Consumer<HttpResponse<?>> responseInterceptor,
+            Duration readTimeout, Duration connectTimeout) {
+        this.builder = builder;
+        this.scheme = scheme;
+        this.host = host;
+        this.port = port;
+        this.basePath = basePath;
+        this.requestInterceptor = interceptor;
+        this.responseInterceptor = responseInterceptor;
+        this.readTimeout = readTimeout;
+        this.connectTimeout = connectTimeout;
+        final String uriPath = (basePath == null || basePath.isBlank())
+                       ? ""
+                       : "/" + basePath.replaceFirst("^/+", "");
+        this.baseUri = scheme + "://" + host + (port == -1 ? "" : ":" + port) 
+ uriPath;
+    }
+
+    /**
+     * Get an {@link HttpClient} based on the current
+     * {@link HttpClient.Builder}.
+     *
+     * <p>
+     * The returned object is immutable and thread-safe.</p>
+     *
+     * @return The HTTP client.
+     */
+    public HttpClient createHttpClient() {
+        return builder.build();
+    }
+
+    public String getScheme() {
+        return scheme;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public String getBasePath() {
+        return basePath;
+    }
+
+    /**
+     * Get the base URI to resolve the endpoint paths against.
+     *
+     * @return The complete base URI that the rest of the API parameters are
+     * resolved against.
+     */
+    public String getBaseUri() {
+        return baseUri;
+    }
+
+    /**
+     * Get the custom interceptor.
+     *
+     * @return The custom interceptor that was set, or null if there isn't any.
+     */
+    public Consumer<HttpRequest.Builder> getRequestInterceptor() {
+        return requestInterceptor;
+    }
+
+    /**
+     * Get the custom response interceptor.
+     *
+     * @return The custom interceptor that was set, or null if there isn't any.
+     */
+    public Consumer<HttpResponse<?>> getResponseInterceptor() {
+        return responseInterceptor;
+    }
+
+    /**
+     * Get the read timeout that was set.
+     *
+     * @return The read timeout, or null if no timeout was set. Null represents
+     * an infinite wait time.
+     */
+    public Duration getReadTimeout() {
+        return readTimeout;
+    }
+
+    /**
+     * Get connection timeout (in milliseconds).
+     *
+     * @return Timeout in milliseconds
+     */
+    public Duration getConnectTimeout() {
+        return connectTimeout;
+    }
+
+    public static Builder builder() {
+        return new Builder();
+    }
+
+    /**
+     *
+    * <p>
+    * This class can be constructed and modified, then used to instantiate the
+    * various API classes. The API classes use the settings in this class to
+    * configure themselves, but otherwise do not store a link to this 
class.</p>
+    *
+    * <p>
+    * This class is mutable and not synchronized, so it is not thread-safe. 
The API
+    * classes generated from this are immutable and thread-safe.</p>
+     */
+    public static class Builder<T extends Builder<T>> {
+
+        protected HttpClient.Builder builder;
+        protected String scheme;
+        protected String host;
+        protected int port;
+        protected String basePath;
+        protected Consumer<HttpRequest.Builder> interceptor;
+        protected Consumer<HttpResponse<?>> responseInterceptor;
+        protected Duration readTimeout;
+        protected Duration connectTimeout;
+
+        /**
+         * Create an instance of ApiClient.
+         */
+        protected Builder() {
+            this.builder = HttpClient.newBuilder();
+            updateBaseUri(DEFAULT_BASE_URI);
+            interceptor = null;
+            readTimeout = null;
+            connectTimeout = null;
+            responseInterceptor = null;
+        }
+
+        public final T updateBaseUri(String baseUri) {
+            URI uri = URI.create(baseUri);
+            scheme = uri.getScheme();
+            host = uri.getHost();
+            port = uri.getPort();
+            basePath = uri.getRawPath();
+
+            //set the authenticator if we have a user/password defined
+            String userInfo = uri.getUserInfo();
+            if (userInfo != null) {
+                userInfo = userInfo.replace("@", "");
+                int idx = userInfo.indexOf(':');
+                if (idx < 1) throw new IllegalArgumentException("Unsupported 
user information format. 'username:password' expected.");
+                final String user = userInfo.substring(0, idx);
+                final String password = userInfo.substring(idx+1);
+                builder.authenticator(new Authenticator() {
+                    @Override
+                    protected PasswordAuthentication 
getPasswordAuthentication() {
+                        return new PasswordAuthentication(user, 
password.toCharArray());
+                    }
+                });
+            }
+            return (T) this;
+        }
+
+        /**
+         * Set a custom {@link HttpClient.Builder} object to use when creating 
the
+         * {@link HttpClient} that is used by the API client.
+         *
+         * @param builder Custom client builder.
+         * @return This object.
+         */
+        public T setHttpClientBuilder(HttpClient.Builder builder) {
+            this.builder = builder;
+            return (T) this;
+        }
+
+        /**
+         * Get an {@link HttpClient} based on the current
+         * {@link HttpClient.Builder}.
+         *
+         * <p>
+         * The returned object is immutable and thread-safe.</p>
+         *
+         * @return The HTTP client.
+         */
+        public HttpClient getHttpClient() {
+            return builder.build();
+        }
+
+        /**
+         * Set a custom host name for the target service.
+         *
+         * @param host The host name of the target service.
+         * @return This object.
+         */
+        public T setHost(String host) {
+            this.host = host;
+            return (T) this;
+        }
+
+        /**
+         * Set a custom port number for the target service.
+         *
+         * @param port The port of the target service. Set this to -1 to reset 
the
+         * value to the default for the scheme.
+         * @return This object.
+         */
+        public T setPort(int port) {
+            this.port = port;
+            return (T) this;
+        }
+
+        /**
+         * Set a custom base path for the target service, for example '/v2'.
+         *
+         * @param basePath The base path against which the rest of the path is
+         * resolved.
+         * @return This object.
+         */
+        public T setBasePath(String basePath) {
+            this.basePath = basePath;
+            return (T) this;
+        }
+
+        /**
+         * Get the base URI to resolve the endpoint paths against.
+         *
+         * @return The complete base URI that the rest of the API parameters 
are
+         * resolved against.
+         */
+        public String getBaseUri() {
+            return scheme + "://" + host + (port == -1 ? "" : ":" + port) + 
basePath;
+        }
+
+        /**
+         * Set a custom scheme for the target service, for example 'https'.
+         *
+         * @param scheme The scheme of the target service
+         * @return This object.
+         */
+        public T setScheme(String scheme) {
+            this.scheme = scheme;
+            return (T) this;
+        }
+
+        /**
+         * Set a custom request interceptor.
+         *
+         * <p>
+         * A request interceptor is a mechanism for altering each request 
before it
+         * is sent. After the request has been fully configured but not yet 
built,
+         * the request builder is passed into this function for further
+         * modification, after which it is sent out.</p>
+         *
+         * <p>
+         * This is useful for altering the requests in a custom manner, such as
+         * adding headers. It could also be used for logging and 
monitoring.</p>
+         *
+         * @param interceptor A function invoked before creating each request. 
A
+         * value of null resets the interceptor to a no-op.
+         * @return This object.
+         */
+        public T setRequestInterceptor(Consumer<HttpRequest.Builder> 
interceptor) {
+            this.interceptor = interceptor;
+            return (T) this;
+        }
+
+        /**
+         * Get the custom interceptor.
+         *
+         * @return The custom interceptor that was set, or null if there isn't 
any.
+         */
+        public Consumer<HttpRequest.Builder> getRequestInterceptor() {
+            return interceptor;
+        }
+
+        /**
+         * Set a custom response interceptor.
+         *
+         * <p>
+         * This is useful for logging, monitoring or extraction of header
+         * variables</p>
+         *
+         * @param interceptor A function invoked after each request response. A
+         * value of null resets the interceptor to a no-op.
+         * @return This object.
+         */
+        public T setResponseInterceptor(Consumer<HttpResponse<?>> interceptor) 
{
+            this.responseInterceptor = interceptor;
+            return (T) this;
+        }
+
+        /**
+         * Get the custom response interceptor.
+         *
+         * @return The custom interceptor that was set, or null if there isn't 
any.
+         */
+        public Consumer<HttpResponse<?>> getResponseInterceptor() {
+            return responseInterceptor;
+        }
+
+        /**
+         * Set the read timeout for the http client.
+         *
+         * <p>
+         * This is the value used by default for each request, though it can be
+         * overridden on a per-request basis with a request interceptor.</p>
+         *
+         * @param readTimeout The read timeout used by default by the http 
client.
+         * Setting this value to null resets the timeout to an effectively 
infinite
+         * value.
+         * @return This object.
+         */
+        public T setReadTimeout(Duration readTimeout) {
+            this.readTimeout = readTimeout;
+            return (T) this;
+        }
+
+        /**
+         * Get the read timeout that was set.
+         *
+         * @return The read timeout, or null if no timeout was set. Null 
represents
+         * an infinite wait time.
+         */
+        public Duration getReadTimeout() {
+            return readTimeout;
+        }
+
+        /**
+         * Sets the connect timeout (in milliseconds) for the http client.
+         *
+         * <p>
+         * In the case where a new connection needs to be established, if the
+         * connection cannot be established within the given {@code
+         * duration}, then {@link HttpClient#send(HttpRequest,BodyHandler)
+         * HttpClient::send} throws an {@link HttpConnectTimeoutException}, or 
     {@link HttpClient#sendAsync(HttpRequest,BodyHandler)
+       * HttpClient::sendAsync} completes exceptionally with an
+         * {@code HttpConnectTimeoutException}. If a new connection does not 
need to
+         * be established, for example if a connection can be reused from a 
previous
+         * request, then this timeout duration has no effect.
+         *
+         * @param connectTimeout connection timeout in milliseconds
+         *
+         * @return This object.
+         */
+        public T setConnectTimeout(Duration connectTimeout) {
+            this.connectTimeout = connectTimeout;
+            this.builder.connectTimeout(connectTimeout);
+            return (T) this;
+        }
+
+        /**
+         * Get connection timeout (in milliseconds).
+         *
+         * @return Timeout in milliseconds
+         */
+        public Duration getConnectTimeout() {
+            return connectTimeout;
+        }
+
+        public ServiceConfiguration build() {
+            return new ServiceConfiguration(builder, scheme, host, port, 
basePath,
+                    interceptor, responseInterceptor, readTimeout, 
connectTimeout);
+        }
+    }
+
+}
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceException.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceException.java
new file mode 100644
index 0000000000..9951d61b67
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceException.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.service;
+
+import java.net.http.HttpHeaders;
+
+/**
+ * HTTP request exception returned by an OpenAPI implementation.
+ */
+public final class ServiceException extends Exception {
+
+    private int code = 0;
+    private HttpHeaders responseHeaders = null;
+    private String responseBody = null;
+
+    public ServiceException() {}
+
+    public ServiceException(Throwable throwable) {
+        super(throwable);
+    }
+
+    public ServiceException(String message) {
+        super(message);
+    }
+
+    public ServiceException(String message, Throwable throwable, int code, 
HttpHeaders responseHeaders, String responseBody) {
+        super(message, throwable);
+        this.code = code;
+        this.responseHeaders = responseHeaders;
+        this.responseBody = responseBody;
+    }
+
+    public ServiceException(String message, int code, HttpHeaders 
responseHeaders, String responseBody) {
+        this(message, (Throwable) null, code, responseHeaders, responseBody);
+    }
+
+    public ServiceException(String message, Throwable throwable, int code, 
HttpHeaders responseHeaders) {
+        this(message, throwable, code, responseHeaders, null);
+    }
+
+    public ServiceException(int code, HttpHeaders responseHeaders, String 
responseBody) {
+        this((String) null, (Throwable) null, code, responseHeaders, 
responseBody);
+    }
+
+    public ServiceException(int code, String message) {
+        super(message);
+        this.code = code;
+    }
+
+    public ServiceException(int code, String message, HttpHeaders 
responseHeaders, String responseBody) {
+        this(code, message);
+        this.responseHeaders = responseHeaders;
+        this.responseBody = responseBody;
+    }
+
+    /**
+     * Get the HTTP status code.
+     *
+     * @return HTTP status code
+     */
+    public int getCode() {
+        return code;
+    }
+
+    /**
+     * Get the HTTP response headers.
+     *
+     * @return Headers as an HttpHeaders object
+     */
+    public HttpHeaders getResponseHeaders() {
+        return responseHeaders;
+    }
+
+    /**
+     * Get the HTTP response body.
+     *
+     * @return Response body in the form of string
+     */
+    public String getResponseBody() {
+        return responseBody;
+    }
+}
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceRequest.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceRequest.java
new file mode 100644
index 0000000000..a0cf7cf209
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/ServiceRequest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.service;
+
+import java.net.http.HttpRequest;
+import java.net.http.HttpResponse;
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * A request configured.
+ * It can be customized using the builder method before sending it.
+ *
+ * @author Johann Sorel (Geomatys)
+ * @param <T> request response type.
+ */
+public final class ServiceRequest<T> {
+
+    private final AbstractService service;
+    private final HttpRequest.Builder builder;
+    private final HttpResponse.BodyHandler<T> bodyHandler;
+
+    public ServiceRequest(AbstractService service, HttpRequest.Builder 
builder, HttpResponse.BodyHandler<T> bodyHandler) {
+        this.service = service;
+        this.builder = builder;
+        this.bodyHandler = bodyHandler;
+    }
+
+    /**
+     * Get the request builder, can be modified before sending the request.
+     *
+     * @return request builder.
+     */
+    public HttpRequest.Builder builder() {
+        return builder;
+    }
+
+    /**
+     * Send request and block until response is parsed.
+     *
+     * @return HttpResponse
+     * @throws ServiceException if fails to make API call
+     */
+    public HttpResponse<T> send() throws ServiceException {
+        return service.send(builder.build(), bodyHandler);
+    }
+
+    /**
+     * Send request in an asynchrone way, method does not block the current 
thread.
+     * @return a future HttpResponse
+     */
+    public CompletableFuture<HttpResponse<T>> sendAsync() {
+        return service.sendAsync(builder.build(), bodyHandler);
+    }
+}
diff --git 
a/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/UncheckedServiceException.java
 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/UncheckedServiceException.java
new file mode 100644
index 0000000000..1678a819f8
--- /dev/null
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/UncheckedServiceException.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sis.storage.web.service;
+
+import java.net.http.HttpHeaders;
+
+/**
+ * HTTP request exception returned by an OpenAPI implementation.
+ */
+public final class UncheckedServiceException extends RuntimeException {
+
+    private int code = 0;
+    private HttpHeaders responseHeaders = null;
+    private String responseBody = null;
+
+    public UncheckedServiceException() {}
+
+    public UncheckedServiceException(Throwable throwable) {
+        super(throwable);
+    }
+
+    public UncheckedServiceException(String message) {
+        super(message);
+    }
+
+    public UncheckedServiceException(String message, Throwable throwable, int 
code, HttpHeaders responseHeaders, String responseBody) {
+        super(message, throwable);
+        this.code = code;
+        this.responseHeaders = responseHeaders;
+        this.responseBody = responseBody;
+    }
+
+    public UncheckedServiceException(String message, int code, HttpHeaders 
responseHeaders, String responseBody) {
+        this(message, (Throwable) null, code, responseHeaders, responseBody);
+    }
+
+    public UncheckedServiceException(String message, Throwable throwable, int 
code, HttpHeaders responseHeaders) {
+        this(message, throwable, code, responseHeaders, null);
+    }
+
+    public UncheckedServiceException(int code, HttpHeaders responseHeaders, 
String responseBody) {
+        this((String) null, (Throwable) null, code, responseHeaders, 
responseBody);
+    }
+
+    public UncheckedServiceException(int code, String message) {
+        super(message);
+        this.code = code;
+    }
+
+    public UncheckedServiceException(int code, String message, HttpHeaders 
responseHeaders, String responseBody) {
+        this(code, message);
+        this.responseHeaders = responseHeaders;
+        this.responseBody = responseBody;
+    }
+
+    /**
+     * Get the HTTP status code.
+     *
+     * @return HTTP status code
+     */
+    public int getCode() {
+        return code;
+    }
+
+    /**
+     * Get the HTTP response headers.
+     *
+     * @return Headers as an HttpHeaders object
+     */
+    public HttpHeaders getResponseHeaders() {
+        return responseHeaders;
+    }
+
+    /**
+     * Get the HTTP response body.
+     *
+     * @return Response body in the form of string
+     */
+    public String getResponseBody() {
+        return responseBody;
+    }
+}
diff --git a/incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/package-info.java
similarity index 51%
copy from incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java
copy to 
incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/package-info.java
index 3cc8d1f841..081ac27646 100644
--- a/incubator/src/org.apache.sis.storage.ogcwxs/main/module-info.java
+++ 
b/incubator/src/org.apache.sis.storage.ogcwxs/main/org/apache/sis/storage/web/service/package-info.java
@@ -16,15 +16,29 @@
  */
 
 /**
- * Data stores for the <abbr>OGC</abbr> web services of the W*S family
- * (<abbr>WMS</abbr>, <abbr>WMTS</abbr>, <abbr>WFS</abbr>, <abbr>WCS</abbr>, 
…).
+ * Abstract distant API utilities for web clients.
+ *
+ * <p>
+ * Exemple :
+ * <pre>
+ * ServiceConfiguration conf = ServiceConfiguration.builder();
+ *  .setBasePath("https://server.com/something-api";)
+ *  .setOther(....)
+ *  .build();
+ *
+ * ServiceApi api = new ServiceApi(conf);
+ * try {
+ *     Result result = api.getSomething(...);
+ *     System.out.println(result);
+ * } catch (ApiException e) {
+ *     System.err.println("Exception when calling ServiceApi#getSomething");
+ *     System.err.println("Status code: " + e.getCode());
+ *     System.err.println("Reason: " + e.getResponseBody());
+ *     System.err.println("Response headers: " + e.getResponseHeaders());
+ *     e.printStackTrace();
+ * }
+ * </pre>
+ *
  *
- * @author Johann Sorel (Geomatys)
  */
-module org.apache.sis.storage.ogcwxs {
-    // Dependencies used in public API.
-    requires transitive org.apache.sis.storage;
-
-    // Uncomment when the package contains at least one class.
-    // exports org.apache.sis.storage.ogcwxs;
-}
+package org.apache.sis.storage.web.service;

Reply via email to