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 =
33 <?xml version="1.0" encoding="UTF-8"?>
34 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
44 public IhcBaseService(IhcConnectionPool ihcConnectionPool, int timeout, String host, String service) {
45 super(ihcConnectionPool);
46 this.timeout = timeout;
47 this.url = createUrl(host, service);
50 private String createUrl(String host, String service) {
51 return "https://" + host + "/ws/" + service;
54 protected String sendSoapQuery(String soapAction, String query) throws IhcExecption {
55 return sendSoapQuery(soapAction, query, timeout);
58 protected String sendSoapQuery(String soapAction, String query, int timeout) throws IhcExecption {
59 Map<String, String> reqProperties = null;
60 if (soapAction != null) {
61 reqProperties = new HashMap<>();
62 reqProperties.put("SOAPAction", soapAction);
64 return sendQuery(url, reqProperties, query, timeout);
67 protected int getTimeout() {