@Override
    public void onError(Exception e) throws Exception {
      log.error("onError(): ", e);

      if (handler != null) {
        handler.onError(e);
      } else {
        throw e;
      }
    }
    @Override
    public void attachment(
        String contentType, InputStream content, Map<String, String> additionalHeaders)
        throws Exception {
      log.trace("attachment({})", contentType);

      if (handler != null) {
        handler.attachment(contentType, content, additionalHeaders);
      } else {
        throw new CodedException(X_INTERNAL_ERROR, "No soap message handler present");
      }
    }
    @Override
    public void soap(SoapMessage message) throws Exception {
      log.trace("soap({})", message.getXml());

      requestSoap = (SoapMessageImpl) message;
      requestServiceId = requestSoap.getService();

      if (handler == null) {
        chooseHandler();
      }

      handler.soap(message);
    }
    @Override
    public void onCompleted() {
      log.trace("onCompleted()");

      if (requestSoap == null) {
        setError(new ClientException(X_MISSING_SOAP, "Request does not contain SOAP message"));
        return;
      }

      if (handler != null) {
        handler.onCompleted();
      }

      try {
        logRequestMessage();
      } catch (Exception e) {
        setError(e);
      }
    }
 @Override
 public void close() {
   handler.close();
 }