Exemple #1
0
void FetchEntryJob::Private::getEntryError(const KDSoapMessage &fault)
{
    if (!q->handleLoginError(fault)) {
        kWarning() << "Fetch Entry Error:" << fault.faultAsString();

        q->setError(SugarJob::SoapError);
        q->setErrorText(fault.faultAsString());
        q->emitResult();
    }
}
Exemple #2
0
 void testInvalidXML()
 {
     HttpServerThread server(QByteArray(xmlEnvBegin11()) + "><soap:Body><broken></xml></soap:Body>", HttpServerThread::Public);
     KDSoapClientInterface client(server.endPoint(), QString::fromLatin1("urn:msg"));
     KDSoapMessage message;
     KDSoapMessage ret = client.call(QLatin1String("Method1"), message);
     QVERIFY(ret.isFault());
     QCOMPARE(ret.faultAsString(), QString::fromLatin1(
                  "Fault code 3: XML error: [1:354] Opening and ending tag mismatch."));
 }
Exemple #3
0
 void testFault() // HTTP error, creates fault on client side
 {
     HttpServerThread server(QByteArray(), HttpServerThread::Public | HttpServerThread::Error404);
     KDSoapClientInterface client(server.endPoint(), QString::fromLatin1("urn:msg"));
     KDSoapMessage message;
     KDSoapMessage ret = client.call(QLatin1String("Method1"), message);
     QVERIFY(ret.isFault());
     QCOMPARE(ret.faultAsString(), QString::fromLatin1(
                  "Fault code 203: Error downloading %1 - server replied: Not Found").arg(server.endPoint()));
 }
Exemple #4
0
 void testInvalidUndefinedEntityXML()
 {
     HttpServerThread server(QByteArray(xmlEnvBegin11()) + "><soap:Body>&doesnotexist;</soap:Body>" + xmlEnvEnd() + '\n', HttpServerThread::Public);
     KDSoapClientInterface client(server.endPoint(), QString::fromLatin1("urn:msg"));
     KDSoapMessage message;
     KDSoapMessage ret = client.call(QLatin1String("Method1"), message);
     QVERIFY(ret.isFault());
     QCOMPARE(ret.faultAsString(), QString::fromLatin1(
                  "Fault code 3: XML error: [1:291] Entity 'doesnotexist' not declared."));
 }
void KDSoapServerSocket::sendReply(KDSoapServerObjectInterface* serverObjectInterface, const KDSoapMessage& replyMsg)
{
    const bool isFault = replyMsg.isFault();

    QByteArray xmlResponse;
    if (!replyMsg.isNull()) {
        KDSoapMessageWriter msgWriter;
        // Note that the kdsoap client parsing code doesn't care for the name (except if it's fault), even in
        // Document mode. Other implementations do, though.
        QString responseName = isFault ? QString::fromLatin1("Fault") : replyMsg.name();
        if (responseName.isEmpty())
            responseName = m_method;
        QString responseNamespace = m_messageNamespace;
        KDSoapHeaders responseHeaders;
        if (serverObjectInterface) {
            responseHeaders = serverObjectInterface->responseHeaders();
            if (!serverObjectInterface->responseNamespace().isEmpty()) {
                responseNamespace = serverObjectInterface->responseNamespace();
            }
        }
        msgWriter.setMessageNamespace(responseNamespace);
        xmlResponse = msgWriter.messageToXml(replyMsg, responseName, responseHeaders, QMap<QString, KDSoapMessage>());
    }

    const QByteArray response = httpResponseHeaders(isFault, "text/xml", xmlResponse.size());
    if (m_doDebug) {
        qDebug() << "KDSoapServerSocket: writing" << response << xmlResponse;
    }
    qint64 written = write(response);
    Q_ASSERT(written == response.size()); // Please report a bug if you hit this.
    written = write(xmlResponse);
    Q_ASSERT(written == xmlResponse.size()); // Please report a bug if you hit this.
    Q_UNUSED(written);
    // flush() ?

    // All done, check if we should log this
    KDSoapServer* server = m_owner->server();
    const KDSoapServer::LogLevel logLevel = server->logLevel(); // we do this here in order to support dynamic settings changes (at the price of a mutex)
    if (logLevel != KDSoapServer::LogNothing) {
        if (logLevel == KDSoapServer::LogEveryCall ||
                (logLevel == KDSoapServer::LogFaults && isFault)) {

            if (isFault)
                server->log("FAULT " + m_method.toLatin1() + " -- " + replyMsg.faultAsString().toUtf8() + '\n');
            else
                server->log("CALL " + m_method.toLatin1() + '\n');
        }
    }
}
Exemple #6
0
int main(int argc, char **argv)
{
    QCoreApplication app(argc, argv);

    const int year = 2009;

    const QString endPoint = QLatin1String("http://www.holidaywebservice.com/Holidays/US/Dates/USHolidayDates.asmx");
    const QString messageNamespace = QLatin1String("http://www.27seconds.com/Holidays/US/Dates/");
    KDSoapClientInterface client(endPoint, messageNamespace);

    KDSoapMessage message;
    message.setQualified(true);
    message.addArgument(QLatin1String("year"), year);

    qDebug("Looking up the date of Valentine's Day in %i...", year);

    KDSoapMessage response = client.call(QLatin1String("GetValentinesDay"), message);
    if (response.isFault())
        printf("%s\n", qPrintable(response.faultAsString()));
    else
        printf("%s\n", qPrintable(response.arguments()[0].value().toString()));

    return 0;
}