// 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); }
QDebug operator <<(QDebug dbg, const KDSoapValue &value) { dbg.space() << value.name() << value.value(); if (!value.childValues().isEmpty()) { dbg << "<children>"; KDSoapValueListIterator it(value.childValues()); while (it.hasNext()) { const KDSoapValue &child = it.next(); dbg << child; } dbg << "</children>"; } if (!value.childValues().attributes().isEmpty()) { dbg << "<attributes>"; QListIterator<KDSoapValue> it(value.childValues().attributes()); while (it.hasNext()) { const KDSoapValue &child = it.next(); dbg << child; } dbg << "</attributes>"; } return dbg; }
void KDSoapFaultException::deserialize(const KDSoapValue &mainValue) { Q_ASSERT(mainValue.name() == QLatin1String("Fault")); const KDSoapValueList &args = mainValue.childValues(); for (int argNr = 0; argNr < args.count(); ++argNr) { const KDSoapValue &val = args.at(argNr); const QString name = val.name(); if (name == QLatin1String("faultcode")) { d->m_faultCode = val.value().value<QString>(); } else if (name == QLatin1String("faultstring")) { d->m_faultString = val.value().value<QString>(); } else if (name == QLatin1String("faultactor")) { d->m_faultActor = val.value().value<QString>(); } } }