19 #include <QAuthenticator>
22 #include <QNetworkProxy>
23 #include <QNetworkReply>
24 #include <QNetworkRequest>
25 #include <QSslConfiguration>
54 : m_accessManager(nullptr)
58 , m_ignoreSslErrors(false)
59 , m_timeout(30 * 60 * 1000)
77 connect(
m_accessManager, &QNetworkAccessManager::authenticationRequired,
this, &KDSoapClientInterfacePrivate::_kd_slotAuthenticationRequired);
84 QNetworkRequest request(QUrl(this->
m_endPoint));
86 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
88 request.setAttribute(QNetworkRequest::Http2AllowedAttribute,
false);
91 QString soapAction = action;
93 if (soapAction.isNull()) {
98 if (!soapAction.endsWith(QLatin1Char(
'/'))) {
99 soapAction += QLatin1Char(
'/');
101 soapAction += method;
107 soapHeader += QString::fromLatin1(
"text/xml;charset=utf-8");
108 request.setRawHeader(
"SoapAction",
'\"' + soapAction.toUtf8() +
'\"');
110 soapHeader += QString::fromLatin1(
"application/soap+xml;charset=utf-8");
112 soapHeader += QString::fromLatin1(
";action=") + soapAction;
115 request.setHeader(QNetworkRequest::ContentTypeHeader, soapHeader.toUtf8());
123 request.setRawHeader(
"Accept-Encoding",
"compress");
126 request.setRawHeader(it.key(), it.value());
143 QBuffer *buffer =
new QBuffer;
154 if (!prop.
action().isEmpty())
155 qWarning(
"Overwriting the action addressing parameter (%s) with the SOAP action (%s)",
156 prop.
action().toLocal8Bit().constData(), soapAction.toLocal8Bit().constData());
159 setBufferData(messageCopy);
161 setBufferData(message);
163 buffer->open(QIODevice::ReadOnly);
172 QNetworkReply *reply = d->
accessManager()->post(request, buffer);
205 QNetworkReply *reply = d->
accessManager()->post(request, buffer);
208 QObject::connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
209 QObject::connect(reply, &QNetworkReply::finished, buffer, &QBuffer::deleteLater);
212 void KDSoapClientInterfacePrivate::_kd_slotAuthenticationRequired(QNetworkReply *reply, QAuthenticator *authenticator)
257 class TimeoutHandler :
public QTimer
261 TimeoutHandler(QNetworkReply *reply)
269 QNetworkReply *reply = qobject_cast<QNetworkReply *>(parent());
273 reply->setProperty(
"kdsoap_reply_timed_out",
true);
282 QObject::connect(reply, &QNetworkReply::sslErrors, reply, QOverload<>::of(&QNetworkReply::ignoreSslErrors));
294 TimeoutHandler *timeoutHandler =
new TimeoutHandler(reply);
295 connect(timeoutHandler, &TimeoutHandler::timeout, timeoutHandler, &TimeoutHandler::replyTimeout);
322 QObject *oldParent = jar->parent();
324 jar->setParent(oldParent);
372 #ifndef QT_NO_OPENSSL
392 #include "KDSoapClientInterface.moc"
393 #include "moc_KDSoapClientInterface_p.cpp"
void maybeDebugRequest(const QByteArray &data, const QNetworkRequest &request, QNetworkReply *reply)
KDSoap::SoapVersion m_version
QNetworkAccessManager * m_accessManager
KDSoapClientInterface::Style m_style
KDSoapSslHandler * m_sslHandler
QMap< QString, KDSoapMessage > m_persistentHeaders
KDSoapClientInterfacePrivate()
void setupReply(QNetworkReply *reply)
QNetworkRequest prepareRequest(const QString &method, const QString &action)
KDSoapHeaders m_lastResponseHeaders
QNetworkAccessManager * accessManager()
QSslConfiguration m_sslConfiguration
KDSoapAuthentication m_authentication
QMap< QByteArray, QByteArray > m_httpHeaders
QString m_messageNamespace
QBuffer * prepareRequestBuffer(const QString &method, const KDSoapMessage &message, const QString &soapAction, const KDSoapHeaders &headers)
~KDSoapClientInterfacePrivate()
bool m_sendSoapActionInHttpHeader
bool m_sendSoapActionInWsAddressingHeader
QList< QSslError > m_ignoreErrorsList
KDSoapClientThread m_thread
void setSoapVersion(KDSoapClientInterface::SoapVersion version)
void callNoReply(const QString &method, const KDSoapMessage &message, const QString &soapAction=QString(), const KDSoapHeaders &headers=KDSoapHeaders())
void setProxy(const QNetworkProxy &proxy)
QSslConfiguration sslConfiguration() const
KDSoapPendingCall asyncCall(const QString &method, const KDSoapMessage &message, const QString &soapAction=QString(), const KDSoapHeaders &headers=KDSoapHeaders())
KDSoapSslHandler * sslHandler() const
void setRawHTTPHeaders(const QMap< QByteArray, QByteArray > &headers)
QNetworkProxy proxy() const
bool sendSoapActionInHttpHeader() const
sendActionInHTTP_Header
bool sendSoapActionInWsAddressingHeader() const
sendSoapActionInWsAddressingHeader
void setCookieJar(QNetworkCookieJar *jar)
QNetworkCookieJar * cookieJar() const
KDSoapClientInterface(const QString &endPoint, const QString &messageNamespace)
void setSslConfiguration(const QSslConfiguration &config)
KDSoapHeaders lastResponseHeaders() const
@ RPCStyle
the method name is sent as an xml element wrapping the message parameters
void setEndPoint(const QString &endPoint)
void setStyle(Style style)
KDSoapMessage call(const QString &method, const KDSoapMessage &message, const QString &soapAction=QString(), const KDSoapHeaders &headers=KDSoapHeaders())
void setSendSoapActionInHttpHeader(bool sendInHttpHeader)
setSendSoapActionInHttpHeader
void setSendSoapActionInWsAddressingHeader(bool sendInWsAddressingHeader)
setSendSoapActionInWsAddressingHeader
void setAuthentication(const KDSoapAuthentication &authentication)
void setHeader(const QString &name, const KDSoapMessage &header)
KDSoapClientInterface::SoapVersion soapVersion() const
void setTimeout(int msecs)
void enqueue(KDSoapThreadTaskData *taskData)
void setAction(const QString &action)
QByteArray messageToXml(const KDSoapMessage &message, const QString &method, const KDSoapHeaders &headers, const QMap< QString, KDSoapMessage > &persistentHeaders, const KDSoapAuthentication &authentication=KDSoapAuthentication()) const
void setMessageNamespace(const QString &ns)
void setVersion(KDSoap::SoapVersion version)
void setMessageAddressingProperties(const KDSoapMessageAddressingProperties &map)
KDSoapMessageAddressingProperties messageAddressingProperties() const
A class for handling SSL errors during SOAP calls.
KDSoapAuthentication m_authentication
KDSoapMessage response() const
KDSoapHeaders responseHeaders() const