KDSoap
KDSoap copied to clipboard
Incorrect fault message is sent from server side if request contained parse errors.
If i send the server a SOAP message which contains parse errors I receive the following message:
<soap:Body>
<soap:Fault>
<faultcode>Client.Data</faultcode>
<faultstring>Request was a fault</faultstring>
</soap:Fault>
</soap:Body>
In the function KDSoapServerSocket::handleRequest
we have the following bit of code:
KDSoapMessage replyMsg;
replyMsg.setUse(server->use());
.
.
.
// parse message
KDSoapMessage requestMsg;
KDSoapHeaders requestHeaders;
KDSoapMessageReader reader;
KDSoapMessageReader::XmlError err = reader.xmlToMessage(receivedData, &requestMsg, &m_messageNamespace, &requestHeaders, KDSoap::SOAP1_1);
if (err == KDSoapMessageReader::PrematureEndOfDocumentError) {
// qDebug() << "Incomplete SOAP message, wait for more data";
// This should never happen, since we check for content-size above.
return;
} // TODO handle parse errors?
After calling xmlToMessage
the requestMsg
will contain a decent parse error message. But the replyMsg
remains unchanged! So when we get to this part of the code:
if (!replyMsg.isFault()) {
makeCall(serverObjectInterface, requestMsg, replyMsg, requestHeaders, soapAction, path);
}
we assume everything is fine and try to process the request on the server object with the requestMsg
. At the start of the function makeCall
we have:
if (requestMsg.isFault()) {
// Can this happen? Getting a fault as a request !? Doesn't make sense...
// reply with a fault, but we don't even know what main element name to use
// Oh well, just use the incoming fault :-)
replyMsg = requestMsg;
handleError(replyMsg, "Client.Data", QString::fromLatin1("Request was a fault"));
}
where handleError
is defined like this:
void KDSoapServerSocket::handleError(KDSoapMessage &replyMsg, const char *errorCode, const QString &error)
{
qWarning("%s", qPrintable(error));
const KDSoap::SoapVersion soapVersion = KDSoap::SOAP1_1; // TODO version selection on the server side
replyMsg.createFaultMessage(QString::fromLatin1(errorCode), error, soapVersion);
}
So what happens is altough we want to use the "incoming" fault as reply fault, the handleError
method calls the createFaultMessage
function which replaces the parse error with the "Request was a fault" error.