当前位置: 首页>>代码示例>>C++>>正文


C++ KDSoapMessage类代码示例

本文整理汇总了C++中KDSoapMessage的典型用法代码示例。如果您正苦于以下问题:C++ KDSoapMessage类的具体用法?C++ KDSoapMessage怎么用?C++ KDSoapMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了KDSoapMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handleError

void KDSoapServerSocket::handleError(KDSoapMessage &replyMsg, const char *errorCode, const QString &error)
{
    qWarning("%s", qPrintable(error));
    replyMsg.setFault(true);
    replyMsg.addArgument(QString::fromLatin1("faultcode"), QString::fromLatin1(errorCode));
    replyMsg.addArgument(QString::fromLatin1("faultstring"), error);
}
开发者ID:nbeudez,项目名称:KDSoap,代码行数:7,代码来源:KDSoapServerSocket.cpp

示例2: processRequest

void KDSoapServerObjectInterface::processRequest(const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction)
{
    const QString method = request.name();
    qDebug() << "Slot not found:" << method << "[soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
    const KDSoap::SoapVersion soapVersion = KDSoap::SOAP1_1; // TODO version selection on the server side
    response.createFaultMessage(QString::fromLatin1("Server.MethodNotFound"), QString::fromLatin1("%1 not found").arg(method), soapVersion);
}
开发者ID:KDAB,项目名称:KDSoap,代码行数:7,代码来源:KDSoapServerObjectInterface.cpp

示例3: makeCall

void KDSoapServerSocket::makeCall(KDSoapServerObjectInterface* serverObjectInterface, const KDSoapMessage &requestMsg, KDSoapMessage& replyMsg, const KDSoapHeaders& requestHeaders, const QByteArray& soapAction, const QString& path)
{
    Q_ASSERT(serverObjectInterface);
    //const QString method = requestMsg.name();

    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"));
    } else {

        // Call method on m_serverObject
        serverObjectInterface->setRequestHeaders(requestHeaders, soapAction);

        KDSoapServer* server = m_owner->server();
        if (path != server->path()) {
            serverObjectInterface->processRequestWithPath(requestMsg, replyMsg, soapAction, path);
        } else {
            serverObjectInterface->processRequest(requestMsg, replyMsg, soapAction);
        }
        if (serverObjectInterface->hasFault()) {
            //qDebug() << "Got fault!";
            replyMsg.setFault(true);
            serverObjectInterface->storeFaultAttributes(replyMsg);
        }
    }
}
开发者ID:nbeudez,项目名称:KDSoap,代码行数:29,代码来源:KDSoapServerSocket.cpp

示例4: testParseComplexReply

    // Test parsing of complex replies, like with SugarCRM
    void testParseComplexReply()
    {
        HttpServerThread server(complexTypeResponse(), HttpServerThread::Public);
        KDSoapClientInterface client(server.endPoint(), countryMessageNamespace());
        const KDSoapMessage response = client.call(QLatin1String("getEmployeeCountry"), countryMessage());
        QVERIFY(!response.isFault());
        QCOMPARE(response.arguments().count(), 1);
        const KDSoapValueList lst = response.arguments().first().childValues();
        QCOMPARE(lst.count(), 3);
        const KDSoapValue id = lst.first();
        QCOMPARE(id.name(), QString::fromLatin1("id"));
        QCOMPARE(id.value().toString(), QString::fromLatin1("12345"));
        const KDSoapValue error = lst.at(1);
        QCOMPARE(error.name(), QString::fromLatin1("error"));
        const KDSoapValueList errorList = error.childValues();
        QCOMPARE(errorList.count(), 3);
        const KDSoapValue number = errorList.at(0);
        QCOMPARE(number.name(), QString::fromLatin1("number"));
        QCOMPARE(number.value().toString(), QString::fromLatin1("0"));
        const KDSoapValue name = errorList.at(1);
        QCOMPARE(name.name(), QString::fromLatin1("name"));
        QCOMPARE(name.value().toString(), QString::fromLatin1("No Error"));
        const KDSoapValue description = errorList.at(2);
        QCOMPARE(description.name(), QString::fromLatin1("description"));
        QCOMPARE(description.value().toString(), QString::fromLatin1("No Error"));
        const KDSoapValue array = lst.at(2);
        QCOMPARE(array.name(), QString::fromLatin1("testArray"));
        //qDebug() << array;

        // Code from documentation
        const QString sessionId = response.arguments()[0].value().toString();
        Q_UNUSED(sessionId);
    }
开发者ID:cjh1,项目名称:KDSoap,代码行数:34,代码来源:builtinhttp.cpp

示例5: processRequest

void KDSoapServerObjectInterface::processRequest(const KDSoapMessage &request, KDSoapMessage& response, const QByteArray& soapAction)
{
    const QString method = request.name();
    qDebug() << "Slot not found:" << method << "[soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
    response.setFault(true);
    response.addArgument(QString::fromLatin1("faultcode"), QString::fromLatin1("Server.MethodNotFound"));
    response.addArgument(QString::fromLatin1("faultstring"), QString::fromLatin1("%1 not found").arg(method));
}
开发者ID:nbeudez,项目名称:KDSoap,代码行数:8,代码来源:KDSoapServerObjectInterface.cpp

示例6: processRequestWithPath

void KDSoapServerObjectInterface::processRequestWithPath(const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction, const QString &path)
{
    Q_UNUSED(soapAction);
    const QString method = request.name();
    qWarning("Invalid path: \"%s\"", qPrintable(path));
    //qWarning() << "Invalid path:" << path << "[method =" << method << "; soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
    const KDSoap::SoapVersion soapVersion = KDSoap::SOAP1_1; // TODO version selection on the server side
    response.createFaultMessage(QString::fromLatin1("Client.Data"), QString::fromLatin1("Method %1 not found in path %2").arg(method, path), soapVersion);
}
开发者ID:KDAB,项目名称:KDSoap,代码行数:9,代码来源:KDSoapServerObjectInterface.cpp

示例7: testInvalidUndefinedEntityXML

 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."));
 }
开发者ID:hporten,项目名称:KDSoap,代码行数:10,代码来源:builtinhttp.cpp

示例8: testFault

 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()));
 }
开发者ID:cjh1,项目名称:KDSoap,代码行数:10,代码来源:builtinhttp.cpp

示例9: kWarning

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();
    }
}
开发者ID:krf,项目名称:FatCRM,代码行数:10,代码来源:fetchentryjob.cpp

示例10: testInvalidXML

 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."));
 }
开发者ID:cjh1,项目名称:KDSoap,代码行数:10,代码来源:builtinhttp.cpp

示例11: processRequestWithPath

void KDSoapServerObjectInterface::processRequestWithPath(const KDSoapMessage &request, KDSoapMessage &response, const QByteArray &soapAction, const QString &path)
{
    Q_UNUSED(soapAction);
    const QString method = request.name();
    qWarning("Invalid path: \"%s\"", qPrintable(path));
    //qWarning() << "Invalid path:" << path << "[method =" << method << "; soapAction =" << soapAction << "]" /* << "in" << metaObject()->className()*/;
    response.setFault(true);
    response.addArgument(QString::fromLatin1("faultcode"), QString::fromLatin1("Client.Data"));
    response.addArgument(QString::fromLatin1("faultstring"), QString::fromLatin1("Method %1 not found in path %2").arg(method, path));
}
开发者ID:nbeudez,项目名称:KDSoap,代码行数:10,代码来源:KDSoapServerObjectInterface.cpp

示例12: testCallRefusedAuth

 // Test for refused auth, with sync call (i.e. in thread)
 void testCallRefusedAuth()
 {
     HttpServerThread server(countryResponse(), HttpServerThread::BasicAuth);
     KDSoapClientInterface client(server.endPoint(), countryMessageNamespace());
     KDSoapAuthentication auth;
     auth.setUser(QLatin1String("kdab"));
     auth.setPassword(QLatin1String("invalid"));
     client.setAuthentication(auth);
     KDSoapMessage reply = client.call(QLatin1String("getEmployeeCountry"), countryMessage());
     QVERIFY(reply.isFault());
 }
开发者ID:cjh1,项目名称:KDSoap,代码行数:12,代码来源:builtinhttp.cpp

示例13: sendReply

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');
        }
    }
}
开发者ID:nbeudez,项目名称:KDSoap,代码行数:49,代码来源:KDSoapServerSocket.cpp

示例14: storeFaultAttributes

void KDSoapServerObjectInterface::storeFaultAttributes(KDSoapMessage& message) const
{
    // SOAP 1.1  <faultcode>, <faultstring>, <faultfactor>, <detail>
    message.addArgument(QString::fromLatin1("faultcode"), d->m_faultCode);
    message.addArgument(QString::fromLatin1("faultstring"), d->m_faultString);
    message.addArgument(QString::fromLatin1("faultactor"), d->m_faultActor);
    if (d->m_detailValue.isNil() || d->m_detailValue.isNull())
        message.addArgument(QString::fromLatin1("detail"), d->m_detail);
    else {
        KDSoapValueList detailAsList;
        detailAsList.append( d->m_detailValue );
        message.addArgument(QString::fromLatin1("detail"), detailAsList);
    }
    // TODO  : Answer SOAP 1.2  <Code> , <Reason> , <Node> , <Role> , <Detail>
}
开发者ID:nbeudez,项目名称:KDSoap,代码行数:15,代码来源:KDSoapServerObjectInterface.cpp

示例15: testDocumentStyle

    void testDocumentStyle()
    {
        HttpServerThread server(countryResponse(), HttpServerThread::Public);

        KDSoapClientInterface client(server.endPoint(), countryMessageNamespace());
        client.setStyle(KDSoapClientInterface::DocumentStyle);
        QByteArray expectedRequestXml = expectedCountryRequest();

        KDSoapMessage message;
        message = KDSoapValue(QLatin1String("getEmployeeCountry"), QVariant());
        KDSoapValueList& args = message.childValues();
        args.append(KDSoapValue(QLatin1String("employeeName"), QString::fromUtf8("David Ä Faure")));

        {
            KDSoapMessage ret = client.call(QLatin1String("UNUSED"), message);
            // Check what we sent
            QVERIFY(xmlBufferCompare(server.receivedData(), expectedRequestXml));
            QVERIFY(!ret.isFault());
            QCOMPARE(ret.arguments().child(QLatin1String("employeeCountry")).value().toString(), QString::fromLatin1("France"));
        }
    }
开发者ID:cjh1,项目名称:KDSoap,代码行数:21,代码来源:builtinhttp.cpp


注:本文中的KDSoapMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。