2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ihc.internal.ws.services;
15 import java.util.HashMap;
18 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
19 import org.openhab.binding.ihc.internal.ws.http.IhcConnectionPool;
20 import org.openhab.binding.ihc.internal.ws.http.IhcHttpsClient;
23 * Base class for all IHC / ELKO services.
26 * @author Pauli Anttila - Initial contribution
28 public abstract class IhcBaseService extends IhcHttpsClient {
31 protected static final String EMPTY_QUERY =
32 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
33 + "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\n"
35 + " </soapenv:Body>\n"
36 + "</soapenv:Envelope>";
42 public IhcBaseService(IhcConnectionPool ihcConnectionPool, int timeout, String host, String service) {
43 super(ihcConnectionPool);
44 this.timeout = timeout;
45 this.url = createUrl(host, service);
48 private String createUrl(String host, String service) {
49 return "https://" + host + "/ws/" + service;
52 protected String sendSoapQuery(String soapAction, String query) throws IhcExecption {
53 return sendSoapQuery(soapAction, query, timeout);
56 protected String sendSoapQuery(String soapAction, String query, int timeout) throws IhcExecption {
57 Map<String, String> reqProperties = null;
58 if (soapAction != null) {
59 reqProperties = new HashMap<>();
60 reqProperties.put("SOAPAction", soapAction);
62 return sendQuery(url, reqProperties, query, timeout);
65 protected int getTimeout() {