KD SOAP API Documentation 2.2
Loading...
Searching...
No Matches
KDSoapServerObjectInterface.cpp
Go to the documentation of this file.
1/****************************************************************************
2**
3** This file is part of the KD Soap project.
4**
5** SPDX-FileCopyrightText: 2010 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
6**
7** SPDX-License-Identifier: MIT
8**
9****************************************************************************/
13#include <QDebug>
14#include <QPointer>
15
16class KDSoapServerObjectInterface::Private
17{
18public:
19 Private()
20 : m_serverSocket(nullptr)
21 {
22 }
23
24 KDSoapHeaders m_requestHeaders;
25 KDSoapHeaders m_responseHeaders;
26 QString m_faultCode;
27 QString m_faultString;
28 QString m_faultActor;
29 QString m_detail;
30 KDSoapValue m_detailValue;
31 QString m_responseNamespace;
32 QByteArray m_soapAction;
33 // QPointer in case the client disconnects during a delayed response
34 QPointer<KDSoapServerSocket> m_serverSocket;
35};
36
38 : m_value(value)
39 , m_name(name)
40{
41}
42
46
51
56
58{
59 const QString method = request.name();
60 qDebug() << "Slot not found:" << method << "[soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
61 const KDSoap::SoapVersion soapVersion = KDSoap::SOAP1_1; // TODO version selection on the server side
62 response.createFaultMessage(QString::fromLatin1("Server.MethodNotFound"), QString::fromLatin1("%1 not found").arg(method), soapVersion);
63}
64
66{
67 Q_UNUSED(path);
68 Q_UNUSED(contentType);
69 return nullptr;
70}
71
73 const QString &path)
74{
75 Q_UNUSED(soapAction);
76 const QString method = request.name();
77 qWarning("Invalid path: \"%s\"", qPrintable(path));
78 // qWarning() << "Invalid path:" << path << "[method =" << method << "; soapAction =" << soapAction << "]" /* << "in" <<
79 // metaObject()->className();
80 const KDSoap::SoapVersion soapVersion = KDSoap::SOAP1_1; // TODO version selection on the server side
81 response.createFaultMessage(QString::fromLatin1("Client.Data"), QString::fromLatin1("Method %1 not found in path %2").arg(method, path),
82 soapVersion);
83}
84
89
91{
92 d->m_faultCode = otherInterface.d->m_faultCode;
93 d->m_faultString = otherInterface.d->m_faultString;
94 d->m_faultActor = otherInterface.d->m_faultActor;
95 d->m_detail = otherInterface.d->m_detail;
96 d->m_detailValue = otherInterface.d->m_detailValue;
97 d->m_responseHeaders = otherInterface.d->m_responseHeaders;
98 d->m_responseNamespace = otherInterface.d->m_responseNamespace;
99}
100
101void KDSoapServerObjectInterface::setFault(const QString &faultCode, const QString &faultString, const QString &faultActor, const QString &detail)
102{
103 Q_ASSERT(!faultCode.isEmpty());
104 d->m_faultCode = faultCode;
105 d->m_faultString = faultString;
106 d->m_faultActor = faultActor;
107 d->m_detail = detail;
108}
109
110void KDSoapServerObjectInterface::setFault(const QString &faultCode, const QString &faultString, const QString &faultActor, const KDSoapValue &detail)
111{
112 Q_ASSERT(!faultCode.isEmpty());
113 d->m_faultCode = faultCode;
114 d->m_faultString = faultString;
115 d->m_faultActor = faultActor;
116 d->m_detailValue = detail;
117}
118
119void KDSoapServerObjectInterface::storeFaultAttributes(KDSoapMessage &message) const
120{
121 // SOAP 1.1 <faultcode>, <faultstring>, <faultfactor>, <detail>
122 message.addArgument(QString::fromLatin1("faultcode"), d->m_faultCode);
123 message.addArgument(QString::fromLatin1("faultstring"), d->m_faultString);
124 message.addArgument(QString::fromLatin1("faultactor"), d->m_faultActor);
125 if (d->m_detailValue.isNil() || d->m_detailValue.isNull()) {
126 message.addArgument(QString::fromLatin1("detail"), d->m_detail);
127 } else {
128 KDSoapValueList detailAsList;
129 detailAsList.append(d->m_detailValue);
130 message.addArgument(QString::fromLatin1("detail"), detailAsList);
131 }
132 // TODO : Answer SOAP 1.2 <Code> , <Reason> , <Node> , <Role> , <Detail>
133}
134
136{
137 return !d->m_faultCode.isEmpty();
138}
139
141{
142 return d->m_serverSocket;
143}
144
146{
147 return d->m_requestHeaders;
148}
149
150void KDSoapServerObjectInterface::setRequestHeaders(const KDSoapHeaders &headers, const QByteArray &soapAction)
151{
152 d->m_requestHeaders = headers;
153 d->m_soapAction = soapAction;
154 // Prepare for a new request to be handled
155 d->m_faultCode.clear();
156 d->m_responseHeaders.clear();
157}
158
160{
161 d->m_responseHeaders = headers;
162}
163
164KDSoapHeaders KDSoapServerObjectInterface::responseHeaders() const
165{
166 return d->m_responseHeaders;
167}
168
170{
171 return d->m_soapAction;
172}
173
178
179void KDSoapServerObjectInterface::setServerSocket(KDSoapServerSocket *serverSocket)
180{
181 d->m_serverSocket = serverSocket;
182}
183
185{
186 KDSoapServerSocket *socket = responseHandle.serverSocket();
187 if (socket) {
188 socket->sendDelayedReply(this, response);
189 }
190}
191
193{
194 const qint64 written = d->m_serverSocket->write(httpReply);
195 Q_ASSERT(written == httpReply.size()); // Please report a bug if you hit this.
196 Q_UNUSED(written);
197}
198
199void KDSoapServerObjectInterface::writeXML(const QByteArray &reply, bool isFault)
200{
201 d->m_serverSocket->writeXML(reply, isFault);
202}
203
205{
206 d->m_responseNamespace = ns;
207}
208
209QString KDSoapServerObjectInterface::responseNamespace() const
210{
211 return d->m_responseNamespace;
212}
void createFaultMessage(const QString &faultCode, const QString &faultText, KDSoap::SoapVersion soapVersion)
void addArgument(const QString &argumentName, const QVariant &argumentValue, const QString &typeNameSpace=QString(), const QString &typeName=QString())
virtual HttpResponseHeaderItems additionalHttpResponseHeaderItems() const
QVector< HttpResponseHeaderItem > HttpResponseHeaderItems
void setResponseHeaders(const KDSoapHeaders &headers)
KDSoapDelayedResponseHandle prepareDelayedResponse()
void doneProcessingRequestWithPath(const KDSoapServerObjectInterface &otherInterface)
void setFault(const QString &faultCode, const QString &faultString, const QString &faultActor=QString(), const QString &detail=QString())
virtual void processRequestWithPath(const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction, const QString &path)
void writeXML(const QByteArray &reply, bool isFault=false)
void sendDelayedResponse(const KDSoapDelayedResponseHandle &responseHandle, const KDSoapMessage &response)
void writeHTTP(const QByteArray &httpReply)
virtual void processRequest(const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction)
virtual QIODevice * processFileRequest(const QString &path, QByteArray &contentType)
void sendDelayedReply(KDSoapServerObjectInterface *serverObjectInterface, const KDSoapMessage &replyMsg)
QString name() const
int size() const const
void append(const T &value)
QString fromLatin1(const char *str, int size)
bool isEmpty() const const

© Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
https://www.kdab.com/development-resources/qt-tools/kd-soap/
Generated on Sat Apr 20 2024 00:04:25 for KD SOAP API Documentation by doxygen 1.9.8